Encoding Ampersands in Query String

Splash Forums PrettyFaces Users Encoding Ampersands in Query String

This topic contains 7 replies, has 3 voices, and was last updated by  Lincoln Baxter III 6 years, 5 months ago.

Viewing 8 posts - 1 through 8 (of 8 total)
  • Author
    Posts
  • #17920

    mge
    Participant

    I’ve been using Pretty Faces for about a week and I have to say it really makes the JSF experience much much better – thank you.

    One issue that I’ve run into however is that rewritten URLs containing multiple query parameters write the literal ampersand character in the HTML response as opposed to the encoded “&” entity. I noticed this because it was flagged by the HTML Validator plug-in for Firefox.

    My attempts to set up a rewrite rule for this situation haven’t been successful so I’m wondering if I’m doing something wrong here. The rewrite rule is taking a single ‘&’ character and converting it to ‘&’

    The rule is:

    <rewrite inbound=”false” match=”&” substitute=”&”/>

    I’ve also written a custom Processor but that is also yielding the same result. It appears that the rewrite Processor is being called twice, and the second call is the cause of the problem. What am I doing wrong here?

    #20891

    Hmmm, we’ve been doing a bunch of work (specifically christian has been doing most of the work) on fixing these encoding issues, but it’s possible we’ve still missed something.

    First, which version of PrettyFaces are you using, on which server, and which version of JSF?

    Thanks,

    Lincoln

    #20892

    mge
    Participant

    I’m using PrettyFaces 3.2.0 with JSF 1.2 on IBM WAS 7. I just realized some of the entities in my original post were replaced with the ampersand by the forum. The substitute values should have been ‘& amp;’ without the added space.

    Thanks

    #20893

    Try version 3.3.0-SNAPSHOT

    https://github.com/ocpsoft/prettyfaces/wiki/Snapshots

    ~Lincoln

    #20894

    mge
    Participant

    No luck – the raw ampersands were still in the output HTML. I was able to get a simple re-write rule working though. Unfortunately this doesn’t take into account any other XML/HTML entities embedded in the URL, but it’s sufficient for now.

    <rewrite inbound="false" match="& #38;(?!amp;)" substitute="& #38;amp;"/>

    Note – I had to add spaces after the ‘&’.

    Thanks for looking in to this.

    #20895

    Thank you very much for reporting this. It really looks like there is something wrong here. Could you open a ticket for this?

    http://code.google.com/p/prettyfaces/issues/list

    I’ll have a look at this as soon as possible.

    #20896

    mge
    Participant

    Issue #104 has been opened – thank you.

    #20897

    Thank you! We will take a look at this as soon as we can!

Viewing 8 posts - 1 through 8 (of 8 total)

You must be logged in to reply to this topic.

Comments are closed.