Bug 80683 - tag and attribute case changed within php (<?php ?>)
Summary: tag and attribute case changed within php (<?php ?>)
Status: RESOLVED FIXED
Alias: None
Product: quanta
Classification: Miscellaneous
Component: general (show other bugs)
Version: unspecified
Platform: unspecified Linux
: NOR normal
Target Milestone: ---
Assignee: András Manţia
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2004-04-30 12:12 UTC by kde
Modified: 2004-05-11 14:54 UTC (History)
0 users

See Also:
Latest Commit:
Version Fixed In:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description kde 2004-04-30 12:12:45 UTC
Version:           3.3 Bleeding Edge (2004-03-29) (using KDE 3.2.2, Gentoo)
Compiler:          gcc version 3.3.2 20031218 (Gentoo Linux 3.3.2-r5, propolice-3.3-7)
OS:          Linux (i686) release 2.6.5-gentoo

When using 'Convert Tag & Attribute Case...' from the tools menu, the case of php strings enclosed in <?php..?> is altered as well.

I.e. given:

<TD><INPUT TYPE='text' class='formfield' name="CSFHeader[Fax]" value="<?php print($_REQUEST["CSFHeader"]["Fax"]);?>"/></TD>

the output should be:

<td><input type='text' class='formfield' name="CSFHeader[Fax]" value="<?php print($_REQUEST["CSFHeader"]["Fax"]);?>"/></td>

however the actual output is:

<td><input type='text' class='formfield' name="CSFHeader[Fax]" value="<?php print($_REQUEST["csfheader"]["fax"]);?>"/></td>

the case of the strings "CSFHeader" and "Fax" are made lower case, but since they are in <?php..?> they should be left untouched.
Comment 1 András Manţia 2004-05-07 14:36:40 UTC
<html><head><meta name="qrichtext" content="1" /></head><body 
style="font-size:10pt;font-family:Arial">
<p>The problem here is that you used &quot; &quot; to quote the tag 
attribute values, but use &quot; &quot; inside the attribute value as 
well, and this confuses Quanta (and the Kate highlighting), and I'd say 
this is not a problem. I'm not even sure that using &quot; &quot; 
inside &quot; &quot; is correct...</p>
<p> If you change the attribute quotation to ' ' and run the tag 
changing dialog, you will see that it behaves in the correct way.</p>
</body></html>

Comment 2 kde 2004-05-10 10:00:18 UTC
Using "" inside attribute values is ok in this case, because it is inside <?php ?> tags.

Regardless, Quanta shouldnt change the case of things inside <?php ?> tags.
Comment 3 András Manţia 2004-05-10 10:24:32 UTC
On Monday 10 May 2004 11:00, theboywho@ruddyperl.com wrote:
> 10:00 ------- Using "" inside attribute values is ok in this case,
> because it is inside <?php ?> tags.

That's bad. :-( Kate also highlights it wrong than... 

>
> Regardless, Quanta shouldnt change the case of things inside <?php ?>
> tags.

This is not about php at all. It's about getting confused by the 
quotation marks.
When <a href="<? echo "foo" ?>"> is analyzed, there is a search for the 
pair of the first  ". And this is the next " unless it's escaped. So 
this will transalte to:
tag name: a
attribute1: href
attribute1 value: <? echo
attribute2: foo
attribute2 value: ?>

You can easily check in the attribute editor tree or the tag dialog that 
the value for href is "<? echo" only in this case.


When you change the tag case of attributes, the href and foo will be 
changed... I don't see an easy way to solve this, and this happens only 
when the quotation is in this form (and never happens if the PHP area 
is outside of a tag). 
 I'll try to find a solution, but I think it won't be soon.

Comment 4 kde 2004-05-10 11:53:42 UTC
Ah, ok. I understand what you mean now! It was just a small niggle - and I wouldn't consider it critical.

Thanks again anyway.
Comment 5 András Manţia 2004-05-10 12:42:44 UTC
CVS commit by amantia: 

Don't be confused by quotation marks inside a script area which is inside a tag value (like <a href="<? echo "foo" ?>">) 
Hopefully doesn't slow down the parser too much.

CCMAIL: 80683-done@bugs.kde.org


  M +2 -0      ChangeLog   1.262
  M +2 -2      quanta.kdevelop   1.196
  M +22 -1     parsers/tag.cpp   1.62
  M +2 -0      parsers/tag.h   1.46


--- kdewebdev/quanta/ChangeLog  #1.261:1.262
@@ -14,4 +14,6 @@
         - fix a major memory leak, cause of many crashes and instability
         - <fieldset> is not a single tag [#79926]
+        - don't be confused by quotation marks inside a script area which is inside a tag value
+          (like <a href="<? echo "foo" ?>">) [#80683]
 
   - behavioral/user interface changes:

--- kdewebdev/quanta/quanta.kdevelop  #1.195:1.196
@@ -236,8 +236,8 @@
   <kdevfilecreate>
     <filetypes>
-      <type icon="" ext="h" name="C++ header" create="template" >
+      <type icon="" ext="h" create="template" name="C++ header" >
         <descr>Quanta speicfic header</descr>
       </type>
-      <type icon="source_cpp" ext="cpp" name="C++ source" create="template" >
+      <type icon="source_cpp" ext="cpp" create="template" name="C++ source" >
         <descr>A new empty C++ file.</descr>
       </type>

--- kdewebdev/quanta/parsers/tag.cpp  #1.61:1.62
@@ -28,4 +28,8 @@
 #include "resource.h"
 
+#include "parser.h"
+#include "node.h"
+
+
 Tag::Tag()
 {
@@ -191,5 +195,6 @@ void Tag::parse(const QString &p_tagStr,
         while (pos < strLength &&
                (m_tagStr[pos] != quotation ||
-               (m_tagStr[pos] == quotation && m_tagStr[pos-1] == '\\')))
+               (m_tagStr[pos] == quotation &&
+                (m_tagStr[pos-1] == '\\'  || isInsideScript(m_tagStr.mid(valueStartPos, pos - valueStartPos)) ) )))
         {
           pos++;
@@ -551,2 +556,18 @@ void Tag::setDtd(const DTDStruct *dtd)
   m_dtd = dtd;
 }
+
+bool Tag::isInsideScript(const QString &str)
+{
+  //This detects if the last char from str is inside a script area or not, to
+  //treat cases like <a href="<? echo "foo" ?>"> correctly
+  //TODO: speed up if you can...
+  if (str.find(m_dtd->specialAreaStartRx) != -1)
+  {
+    QString foundString = m_dtd->specialAreaStartRx.cap();
+    if (str.find(m_dtd->specialAreas[foundString]) == -1)
+    {
+      return true;
+    }
+  }
+  return false;
+}

--- kdewebdev/quanta/parsers/tag.h  #1.45:1.46
@@ -174,4 +174,6 @@ public:
 private:
   void init();
+  /** Verifies if the last char from @param str is inside a script area or not */
+  bool isInsideScript(const QString& str);
 
   AreaStruct m_area; //where the tag is in the doc


Comment 6 kde 2004-05-11 14:54:17 UTC
Ive been testing this today - it works very well! thank you again!!