This question about Topic Markup Language and applications: Answered

Decoding Html Spaces

I have a hopefully very simple question, that for some reason I can't seem to find an answer to.

I've got one page that has a few form field values. I've wrapped those with
%ENCODE%
so I can pass them as GET parameters using an HTML form.

The target of the form is another page where I'm using
%URLPARAM%
to grab the values and display them.

It works perfectly, except that it doesn't decode the =%20='s back into normal spaces. I'm going to be kicking myself when I know the answer, I'm sure, so if somebody could go ahead and kick me I'd appreciate it big grin

Sample source page (shortened):

<form action="http://twiki.citizensfla.com/bin/view/Main/PushNotificationEmail" method="get">
<input type="hidden" name="date" value=%ENCODE{%FORMFIELD{Date}%}% /> \
<input type="hidden" name="time" value=%ENCODE{%FORMFIELD{Time}%}% /> \
</form>

Date for instance shows up as 21%20Sep%202009

Line from target page:

Scheduled Time: %URLPARAM{"date" encode="entity" }% - %URLPARAM{"time" encode="url" }%

Spaces remain encoded.

Update: Oh, and as you see I was playing with the "encode" attribute for both ENCODE and URLPARAM on and off, but was unable to find a combination that made a difference. Tried both with and without.

I realize decoding stuff received via GET param blindly could be bad - maybe there's a better way I can do this? At the moment I really only care about restoring spaces.

Accepted Answer

You don't have to do this. A value taken from an input will be URL encoded by default. By using ENCODE you are double-encoding the value.

For example,
<form method="GET">
<input type="text" name="blah" value="%FORMFIELD{"Subject"}%" />
<input type="submit" />
</form>
renders to this:

Click the "submit" button to see the result:

Now, if you look in the URL bar, you should see that the parameter is URL encoded (spaces are replaced by + signs)

-- CrawfordCurrie - 21 Oct 2009

Thanks! Based on the above example I found the real problem - the quotes. I didn't think I could do nested double-quotes, so I ended up losing part of my spaced strings before they even made it to being posted to the GET URL. Had misunderstood the problem of being one related to encoding during all the tinkering.

Appreciate it smile

-- RasmusPraestholm - 26 Oct 2009

QuestionForm edit

Subject Topic Markup Language and applications
Extension
Version TWikiRelease04x01x02
Status Answered
Topic revision: r5 - 26 Oct 2009, RasmusPraestholm - This page was cached on 17 Oct 2018 - 19:00.

The copyright of the content on this website is held by the contributing authors, except where stated elsewhere. See Copyright Statement. Creative Commons License    Legal Imprint    Privacy Policy