Bug 76663 - Insert tag from Files tree does not respect attribute quotation setting
Summary: Insert tag from Files tree does not respect attribute quotation setting
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-03-03 17:20 UTC by Dennis Hansen
Modified: 2004-03-03 19:12 UTC (History)
0 users

See Also:
Latest Commit:
Version Fixed In:


Attachments
quote-tag-attribute.patch (1.27 KB, text/x-diff)
2004-03-03 18:28 UTC, Dennis Hansen
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Dennis Hansen 2004-03-03 17:20:36 UTC
Version:           3.3 Bleeding Edge (2004-03-01) (using KDE 3.2.0, compiled sources)
Compiler:          gcc version 3.2.2 (Mandrake Linux 9.1 3.2.2-3mdk)
OS:          Linux (i686) release 2.4.21-0.27mdk

If I right RMB click a file in the Files Tree and choose "Insert Tag" it does not respect my single quote attribute setting from quanta, it will always insert in double quotes,
I get for example this
<a href="file.php"></a>
instead of
<a href='file.php'></a>
Comment 1 Dennis Hansen 2004-03-03 18:28:18 UTC
Attached is a patch that fixes this.
Should be good untill someone complains about it not respecting the 
tag case - uppercase/lowercase :-)

This patch take cares of the quote attribute for <a> and <img> tags
they both had the same problem.


Created an attachment (id=5003)
quote-tag-attribute.patch
Comment 2 András Manţia 2004-03-03 18:49:44 UTC
I'm on my way to create a patch that takes care also of tag/attribute 
case. ;-) It's compiling right now here.

Comment 3 Dennis Hansen 2004-03-03 18:58:12 UTC
Sounds good !
Next time I won't bug report before I got the fix made myself if I can - 
you're so quick :-)

Comment 4 András Manţia 2004-03-03 19:12:42 UTC
CVS commit by amantia: 

Use the correct quotation and case when inserting a link to a file from the treeviews [#76663]

Don't you want to subscribe to our devel list? See https://mail.kde.org/mailman/listinfo/quanta-devel.

CCMAIL: 76663-done@bugs.kde.org


  M +1 -0      ChangeLog   1.238
  M +18 -4     src/quanta.cpp   1.437
  M +8 -0      utility/quantacommon.cpp   1.80
  M +3 -0      utility/quantacommon.h   1.64


--- kdewebdev/quanta/ChangeLog  #1.237:1.238
@@ -44,4 +44,5 @@
         - background parsing: allow user input while parsing [#63000 and its duplicates]
         - load DTEPs only on demand: improves startup performance, uses less memory
+        - use the correct quotation and case when inserting a link to a file from the treeviews [#76663]
     - behavioral changes:
     - new features:

--- kdewebdev/quanta/src/quanta.cpp  #1.436:1.437
@@ -762,7 +762,17 @@ void QuantaApp::slotInsertTag(const KURL
         {
           QString width,height;
-          width.setNum( img.width () );
-          height.setNum( img.height() );
-          w->insertTag("<img src=\""+urlStr+"\" width=\""+width+"\" height=\""+height+"\" border=\"0\">");
+          width.setNum(img.width());
+          height.setNum(img.height());
+          QString imgTag = QuantaCommon::tagCase("<img ");        
+          imgTag += QuantaCommon::attrCase("src=");
+          imgTag += QuantaCommon::quoteAttributeValue(urlStr);
+          imgTag += QuantaCommon::attrCase(" width=");
+          imgTag += QuantaCommon::quoteAttributeValue(width);
+          imgTag += QuantaCommon::attrCase(" height=");
+          imgTag += QuantaCommon::quoteAttributeValue(height);
+          imgTag += QuantaCommon::attrCase(" border=");
+          imgTag += QuantaCommon::quoteAttributeValue(QString("%1").arg(0));
+          imgTag += ">";
+          w->insertTag(imgTag);
           isImage = true;
         }
@@ -770,5 +780,9 @@ void QuantaApp::slotInsertTag(const KURL
       if (!isImage)
       {
-        w->insertTag( "<a href=\""+urlStr+"\">","</a>");
+        QString tag = QuantaCommon::tagCase("<a ");
+        tag += QuantaCommon::attrCase("href=");
+        tag += QuantaCommon::quoteAttributeValue(urlStr);
+        tag += ">";
+        w->insertTag(tag, QuantaCommon::tagCase("</a>"));
       }
     }

--- kdewebdev/quanta/utility/quantacommon.cpp  #1.79:1.80
@@ -101,4 +101,12 @@ QString QuantaCommon::attrCase( const QS
 }
 
+/** returns the attribute value in quoted form, by taking care of the
+quotation setting*/
+QString QuantaCommon::quoteAttributeValue(const QString& value)
+{
+  QString quote = qConfig.attrValueQuotation;
+  return quote + value + quote;
+}
+
 /** Set's up the url correctly from urlString. */
 void QuantaCommon::setUrl(KURL &url, const QString& urlString)

--- kdewebdev/quanta/utility/quantacommon.h  #1.63:1.64
@@ -127,4 +127,7 @@ public:
   /** convert tag to upper or lower case */
   static QString attrCase( const QString& attr);
+/** returns the attribute value in quoted form, by taking care of the
+quotation setting*/
+  static QString quoteAttributeValue(const QString& value);
   /** Set's up the url correctly from urlString. */
   static void setUrl(KURL &url, const QString& urlString);