Bug 112379 - Form completion does not work when name of form element contains []
Summary: Form completion does not work when name of form element contains []
Status: RESOLVED FIXED
Alias: None
Product: kdelibs
Classification: Frameworks and Libraries
Component: general (show other bugs)
Version: unspecified
Platform: Compiled Sources Linux
: NOR major
Target Milestone: ---
Assignee: Thomas Braxton
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2005-09-10 19:58 UTC by Sebastian Kratzert
Modified: 2006-07-01 04:12 UTC (History)
0 users

See Also:
Latest Commit:
Version Fixed In:


Attachments
formcompletion.diff (1.66 KB, patch)
2005-09-10 20:01 UTC, Sebastian Kratzert
Details
patch KConfigBase to handle entries with embedded [] (2.54 KB, patch)
2006-06-28 08:45 UTC, Thomas Braxton
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Sebastian Kratzert 2005-09-10 19:58:47 UTC
Version:            (using KDE KDE 3.4.2)
Installed from:    Compiled From Sources

Hi,

i have a website which uses a lot of form elements. These elements have xpath expressions as names.
The names look like /foo/bar[1]/baz[2]/abc The problem here is that khtml stores formcompletions as KSimpleConfig with
the element name as key. When the form element name contains [], the entry is ignored by KConfig.

Attached is a quick hack which resolves the problem for me. It simply replaces all [ and ] with spaces.
Comment 1 Sebastian Kratzert 2005-09-10 20:01:43 UTC
Created attachment 12521 [details]
formcompletion.diff
Comment 2 Tommi Tervo 2005-09-11 13:39:38 UTC
Dupe of this one #107170?
Comment 3 Sebastian Kratzert 2005-09-11 14:39:57 UTC
No i don't think so. #107170 is only about browsing files.
Comment 4 Thomas Braxton 2006-06-28 08:45:40 UTC
Created attachment 16811 [details]
patch KConfigBase to handle entries with embedded []

This is actually a KConfig bug. KConfig uses [] to delimit the locale and
options/flags on the entry, so an entry with embedded [ or ] confuses the
parser when it tries to read the entry back in. After you apply this patch you
can edit your config files to replace embedded [/] with %5b/%5d and KConfig
should be able to read them back in.
Comment 5 Thomas Braxton 2006-07-01 04:11:59 UTC
SVN commit 556653 by braxton:

allow embedded [] in entry names. This fixes the parser, instead of KConfigBase.

BUG: 112379

 M  +22 -2     kconfigbackend.cpp  


--- branches/KDE/3.5/kdelibs/kdecore/kconfigbackend.cpp #556652:556653
@@ -211,6 +211,26 @@
   return result;
 }
 
+static QCString encodeKey(const char* key)
+{
+    QCString newKey(key);
+
+    newKey.replace('[', "%5b");
+    newKey.replace(']', "%5d");
+
+    return newKey;
+}
+
+static QCString decodeKey(const char* key)
+{
+    QCString newKey(key);
+
+    newKey.replace("%5b", "[");
+    newKey.replace("%5d", "]");
+
+    return newKey;
+}
+
 class KConfigBackEnd::KConfigBackEndPrivate
 {
 public:
@@ -675,7 +695,7 @@
       QCString val = printableToString(st, s - st);
       //qDebug("found key '%s' with value '%s'", key.data(), val.data());
 
-      KEntryKey aEntryKey(aCurrentGroup, key);
+      KEntryKey aEntryKey(aCurrentGroup, decodeKey(key));
       aEntryKey.bLocal = (locale != 0);
       aEntryKey.bDefault = bDefault;
 
@@ -870,7 +890,7 @@
 
      firstEntry = false;
      // it is data for a group
-     fputs(key.mKey.data(), pStream); // Key
+     fputs(encodeKey(key.mKey.data()), pStream); // Key
 
      if ( currentEntry.bNLS )
      {