Bug 118693

Summary: When an action tag includes quotes ("), they get incorrectly escaped when applying action
Product: quanta Reporter: MM <radar>
Component: generalAssignee: András Manţia <amantia>
Status: RESOLVED FIXED    
Severity: normal    
Priority: NOR    
Version: 3.5   
Target Milestone: ---   
Platform: unspecified   
OS: Linux   
Latest Commit: Version Fixed In:

Description MM 2005-12-20 08:41:18 UTC
Version:           3.5 (using KDE 3.5.0, Debian Package 4:3.5.0-1 (testing/unstable))
Compiler:          Target: i486-linux-gnu
OS:                Linux (i686) release 2.6.8-2-686

1. Create a new action of the tag type
2. Set the opening tag to <?=t("
3. Set the closing tag to ")?>
4. Save and maybe assign a shortcut, then type something, select it and trigger the action.

Example: type, select and trigger:
initial -- test
What I get -- <?=t("test\")?>
What I expected -- <?=t("test")?>

The last quote is escaped, which is incorrect (it worked OK with the previous quanta). Moreover it happened once or twice that the first quote got escaped as well (which I can't reproduce)
Comment 1 András Manţia 2005-12-21 16:47:41 UTC
SVN commit 490343 by amantia:

Better handling of quotation marks when editing tags inside a script area.

BUG: 118693

 M  +1 -1      ChangeLog  
 M  +13 -1     src/document.cpp  


--- branches/KDE/3.5/kdewebdev/quanta/ChangeLog #490342:490343
@@ -2,7 +2,7 @@
 
 Version 3.5.1 (Release date: 29-11-2005; Started 04-03-2004):
  - bugfixes:
-        - better handling of quotation marks when editing tags inside a script area
+        - better handling of quotation marks when editing tags inside a script area [#118693]
         - don't show the file changed dialog after using save as and save again
         - crash fixes in VPL [#118686]
 
--- branches/KDE/3.5/kdewebdev/quanta/src/document.cpp #490342:490343
@@ -448,8 +448,20 @@
       if (s[i] == '"' && (i == 0 || s[i-1] != '\\'))
         insideQuotes = !insideQuotes;
     }
-    if (insideQuotes)
+    int eLine, eCol;
+    n->tag->endPos(eLine, eCol);
+    s = this->text(line + 1, col, eLine, eCol);
+    bool closeQuotationFound = false;
+    for (int i = 0 ; i < (int)s.length() - 1; i++)
     {
+      if (s[i] == '"' && (i == 0 || s[i-1] != '\\'))
+      {
+        closeQuotationFound = true;
+        break;
+      }
+    }
+    if (insideQuotes && closeQuotationFound)
+    {
       text.replace("\\\"", "\"");
       text.replace("\"", "\\\"");
     }