Item9522: Configure items containing single quote cannot be restored with use default javascript

Priority: Urgent
Current State: Closed
Released In: 1.1.0
Target Release: minor
Applies To: Engine
Component: Configure
Reported By: GeorgeClark
Waiting For:
Last Change By: KennethLavrsen
The single quote is not encoded and appears to truncate the value in the javascript routine.

This is most noticeable with the parameters:
  • {LoginNameFilterIn}
  • {AccessibleCFG}
  • {NameFilter}

These are pretty complex, so having a way to restore the default is rather important.

A really simple fix of eliminating the single quote from the regex in Foswiki::UI::urlEncode gets things closer. The "use default" then shows the correct string, and functions ... but the restored results are corrupted with \ escapes for newlines, single quotes, etc. And attempting to save after that change (and applying a default) crashes configure. So I removed encoding of newlines and single quotes in UI/ And things seem to be working, but what else have I broken?

+++ b/core/lib/Foswiki/Configure/
@@ -316,7 +316,7 @@ URL encode a value.
 sub urlEncode {
     my ( $this, $value ) = @_;
-    $value =~ s/([^0-9a-zA-Z-_.:~!*'\/])/'%'.sprintf('%02x',ord($1))/ge;
+    $value =~ s/([^0-9a-zA-Z-_.:~!*\/])/'%'.sprintf('%02x',ord($1))/ge;
     return $value;

+++ b/core/lib/Foswiki/Configure/UIs/
@@ -96,8 +96,8 @@ sub renderHtml {
             $defaultDisplayValue ||= '0';
-        $valueString =~ s/\'/\\'/go;
-        $valueString =~ s/\n/\\n/go;
+        #$valueString =~ s/\'/\\'/go;
+        #$valueString =~ s/\n/\\n/go;
         $valueString = $this->urlEncode($valueString);

Setting to urgent to get some visibility / assistance. I'm not sure how to go about fixing this.

-- GeorgeClark - 22 Aug 2010

Actually the above seems to have fixed it - but no idea what else it breaks. So another pair of eyes reviewing this before I commit would be appreciated.

-- GeorgeClark - 22 Aug 2010

Committed the changes. Needs more testing.

-- GeorgeClark - 22 Aug 2010

We should really be emitting this stuff as pure JSON rather than stuffing everyting into <meta> tags, but we'll leave that for 1.2 or later. Good work George.

-- PaulHarvey - 23 Aug 2010

Forgot we have this feature in 1.0.9 already. So Waiting for Release.

-- ArthurClemens - 24 Aug 2010


ItemTemplate edit

Summary Configure items containing single quote cannot be restored with use default javascript
ReportedBy GeorgeClark
Codebase 1.0.9, trunk
SVN Range
AppliesTo Engine
Component Configure
Priority Urgent
CurrentState Closed
Checkins distro:588e999f1149
TargetRelease minor
ReleasedIn 1.1.0
Topic revision: r8 - 04 Oct 2010, KennethLavrsen
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