• Do not register here on develop.twiki.org, login with your twiki.org account.
• Use View topic Item7848 for generic doc work for TWiki-6.1.1. Use View topic Item7851 for doc work on extensions that are not part of a release. More... Close
• Anything you create or change in standard webs (Main, TWiki, Sandbox etc) will be automatically reverted on every SVN update.
Does this site look broken?. Use the LitterTray web for test cases.

Encoded parentheses are needed to pass a regular expression in a url.

If you do a WebSearch with (bla): http://mail.twiki.org/do/view/Bugs/WebSearch?search=%28bla%29 the search string is properly encoded (check search box and url).

But when you write %ENCODE{"(bla)" type="url"}% the parentheses are not encoded. If you pass a url with parentheses to a websearch you won't get the same results. The search is effectively broken.

Test:

   * %ENCODE{"(text with spaces and parentheses)" type="entity"}%
   * %ENCODE{"(text with spaces and parentheses)" type="html"}%
   * %ENCODE{"(text with spaces and parentheses)" type="url"}%
   * %ENCODE{"(text with spaces and parentheses)"}%

results in:

  • (text with spaces and parentheses)
  • (text with spaces and parentheses)
  • (text%20with%20spaces%20and%20parentheses)
  • (text%20with%20spaces%20and%20parentheses)

The code doc at TWiki.pm->urlEncode says:

...Only alphanumerics [0-9a-zA-Z], the special characters $-_.+!*'(), and reserved characters used for their reserved purposes may be used unencoded within a URL.

The fix looks easy: change

    $text =~ s/([^0-9a-zA-Z-_.:~!*'()\/%])/'%'.sprintf('%02x',ord($1))/ge;

to:

    $text =~ s/([^0-9a-zA-Z-_.:~!*'\/%])/'%'.sprintf('%02x',ord($1))/ge;

After the change the test above will print:

  • (text with spaces and parentheses)
  • (text with spaces and parentheses)
  • %28text%20with%20spaces%20and%20parentheses%29
  • %28text%20with%20spaces%20and%20parentheses%29

-- AC

That doesn't sound right at all. The purpose of encoding is to stop an illegal URL being generated, but () are legal in a URL so don't have to be encoded. The text of that comment in TWiki.pm was taken verbatim from the spec of URLs.

Are you trying to use ENCODE for a purpose for which it wasn't intended? Can you please explain the use-case?

CC

Hmm, my examples here work ok:

I must be doing something wrong. Setting to discarded for now.

AC

ItemTemplate
Summary ENCODE does not encode parentheses
ReportedBy TWiki:Main.ArthurClemens
Codebase

SVN Range TWiki-4.1, Tue, 28 Nov 2006, build 12081
AppliesTo Engine
Component

Priority Urgent
CurrentState No Action Required
WaitingFor

Checkins

TargetRelease n/a
Edit | Attach | Watch | Print version | History: r4 < r3 < r2 < r1 | Backlinks | Raw View |  Raw edit | More topic actions
Topic revision: r4 - 2006-12-14 - ArthurClemens
 
This site is powered by the TWiki collaboration platform Powered by PerlCopyright © 2008-2024 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding TWiki? Send feedback