<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "https://bugs.webkit.org/page.cgi?id=bugzilla.dtd">

<bugzilla version="5.0.4.1"
          urlbase="https://bugs.webkit.org/"
          
          maintainer="admin@webkit.org"
>

    <bug>
          <bug_id>53320</bug_id>
          
          <creation_ts>2011-01-28 11:59:17 -0800</creation_ts>
          <short_desc>[Qt] QtWebKit does not properly handle D&amp;D of a percent-encoded URL</short_desc>
          <delta_ts>2011-02-13 12:14:26 -0800</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>1</classification_id>
          <classification>Unclassified</classification>
          <product>WebKit</product>
          <component>WebCore Misc.</component>
          <version>528+ (Nightly build)</version>
          <rep_platform>All</rep_platform>
          <op_sys>All</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>FIXED</resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords>EasyFix, Qt, QtTriaged</keywords>
          <priority>P2</priority>
          <bug_severity>Normal</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Dawit A.">adawit</reporter>
          <assigned_to name="Nobody">webkit-unassigned</assigned_to>
          <cc>aparna.nand</cc>
    
    <cc>benjamin</cc>
    
    <cc>cmarcelo</cc>
    
    <cc>kling</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>341599</commentid>
    <comment_count>0</comment_count>
    <who name="Dawit A.">adawit</who>
    <bug_when>2011-01-28 11:59:17 -0800</bug_when>
    <thetext>When a percent encoded URL is dragged and dropped into QtWebKit (read: QWebView), the QNetworkRequest that is generated will contain an invalid URL. That is because the URL is not properly encoded before being used to create the request. To test, open the test case attached in QtTestBrowser and drag &quot;drag me&quot; link to a second instance of QtTestBrowser.

I believe this bug is caused by the fact that the dragged URL is passed in unencoded format (QUrl::fromEncoded), but the attempt re-encode in QtWebKit&apos;s implementation of DragData::asURL in WebCore/platform/qt/DragDataQt.cpp does not seem to do the job properly. In fact to me the call to encodeWithURLEscapeSequences with the string representation of of the URL seems totally wrong to me since the characters allowed within a URL vary based in each of its separate components (scheme, authority, path, query etc...).</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>341603</commentid>
    <comment_count>1</comment_count>
      <attachid>80475</attachid>
    <who name="Dawit A.">adawit</who>
    <bug_when>2011-01-28 12:00:54 -0800</bug_when>
    <thetext>Created attachment 80475
Test case...</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>341729</commentid>
    <comment_count>2</comment_count>
    <who name="Benjamin Poulain">benjamin</who>
    <bug_when>2011-01-28 14:15:54 -0800</bug_when>
    <thetext>Broken on trunk, good catch.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>341769</commentid>
    <comment_count>3</comment_count>
    <who name="Dawit A.">adawit</who>
    <bug_when>2011-01-28 15:09:13 -0800</bug_when>
    <thetext>(In reply to comment #2)
&gt; Broken on trunk, good catch.

Thanks but I cannot take credit for this... It was reported downstream. See https://bugs.kde.org/show_bug.cgi?id=263788.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>341777</commentid>
    <comment_count>4</comment_count>
    <who name="Dawit A.">adawit</who>
    <bug_when>2011-01-28 15:14:28 -0800</bug_when>
    <thetext>(In reply to comment #0)
&gt; I believe this bug is caused by the fact that the dragged URL is passed in unencoded format (QUrl::fromEncoded), but the attempt re-encode in QtWebKit&apos;s implementation of DragData::asURL in WebCore/platform/qt/DragDataQt.cpp does not seem to do the job properly. In fact to me the call to encodeWithURLEscapeSequences with the string representation of of the URL seems totally wrong to me since the characters allowed within a URL vary based in each of its separate components (scheme, authority, path, query etc...).

I am not longer sure whether the cause for the bug is the call to encodeWithURLEscapeSequences. Maninly because I fail to see how it can be that different from QUrl::toPrecentEncoding... However, I can confirm that the URL sent through the QDropEvent received when one reimplements QWebPage::dropEvent is most definitely not precent encoded.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>341783</commentid>
    <comment_count>5</comment_count>
    <who name="Dawit A.">adawit</who>
    <bug_when>2011-01-28 15:17:55 -0800</bug_when>
    <thetext>(In reply to comment #2)
&gt; Broken on trunk, good catch.

For the record it is also broken in QtWebKit 2.2 which is what I tested this one. I am almost certain the original bug reporter is using the version of QtWebKit that came with Qt. As such it is likely broken in QtWebKit 2.0 as well...</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>350276</commentid>
    <comment_count>6</comment_count>
      <attachid>82235</attachid>
    <who name="Aparna Nandyal">aparna.nand</who>
    <bug_when>2011-02-12 09:41:50 -0800</bug_when>
    <thetext>Created attachment 82235
Patch for review

This bug is due to the wrong encoding done in encodeWithURLEscapeSequences() function. For example

- The url passed -   https://www.google.com/accounts/ServiceLogin?service=mail&amp;passive=true&amp;rm=false&amp;continue=http://mail.google.com/mail/?ui=html&amp;zy=l&amp;bsv=llya694le36z&amp;scc=1&amp;ltmpl=default&amp;ltmplcache=2

- The url returned - https://www.google.com/accounts/ServiceLogin%3Fservice=mail&amp;passive=true&amp;rm=false&amp;continue=http://mail.google.com/mail/%3Fui=html&amp;zy=l&amp;bsv=llya694le36z&amp;scc=1&amp;ltmpl=default&amp;ltmplcache=2

- The url expected - https://www.google.com/accounts/ServiceLogin?service=mail&amp;passive=true&amp;rm=false&amp;continue=http%3A%2F%2Fmail.google.com%2Fmail%2F%3Fui%3Dhtml%26zy%3Dl&amp;bsv=llya694le36z&amp;scc=1&amp;ltmpl=default&amp;ltmplcache=2


The expected URL is obtained when using QUrl&apos;s function toEncoded(). The expected URL (in the encoded form) is infact the url that is there in the html href tag.

As per this analysis there are 2 ways to solve this bug.
1. As in the patch encode the url using toEncoded()
2. Do not do any encoding. Convert the input QUrl to String and pass it back. Replace the fix line with 
return String(urls().first().toString());</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>350277</commentid>
    <comment_count>7</comment_count>
    <who name="Aparna Nandyal">aparna.nand</who>
    <bug_when>2011-02-12 09:46:14 -0800</bug_when>
    <thetext>..Continuing the analysis part (pressed commit button by mistake)
The second approach is the approach taken by the gtk port for example. In this approach the string does not get encoded at this point. 

I took the first approach:
1. It is always better to encode at this point rather then passing the human readable url
2. The encoded url is same as the one in html.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>350391</commentid>
    <comment_count>8</comment_count>
      <attachid>82235</attachid>
    <who name="Andreas Kling">kling</who>
    <bug_when>2011-02-13 06:23:47 -0800</bug_when>
    <thetext>Comment on attachment 82235
Patch for review

View in context: https://bugs.webkit.org/attachment.cgi?id=82235&amp;action=review

Patch looks sensible, just one thing:

&gt; Source/WebCore/platform/qt/DragDataQt.cpp:128
&gt; +    return String(urls.first().toEncoded().constData());

You should use the String constructor that takes a length parameter in addition to the const char*, i.e:
QByteArray encodedUrl = urls.first().toEncoded();
return String(encodedUrl.constData(), encodedUrl.length());</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>350430</commentid>
    <comment_count>9</comment_count>
      <attachid>82272</attachid>
    <who name="Aparna Nandyal">aparna.nand</who>
    <bug_when>2011-02-13 11:45:04 -0800</bug_when>
    <thetext>Created attachment 82272
Patch with comments implemented

Implemented the changes given in the review.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>350434</commentid>
    <comment_count>10</comment_count>
      <attachid>82272</attachid>
    <who name="Andreas Kling">kling</who>
    <bug_when>2011-02-13 11:50:00 -0800</bug_when>
    <thetext>Comment on attachment 82272
Patch with comments implemented

View in context: https://bugs.webkit.org/attachment.cgi?id=82272&amp;action=review

r=me

&gt; Source/WebCore/ChangeLog:5
&gt; +        [Qt] QtWebKit does not properly handle D&amp;D of a precent encoded URL...

Typo, percent.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>350435</commentid>
    <comment_count>11</comment_count>
    <who name="Andreas Kling">kling</who>
    <bug_when>2011-02-13 12:14:26 -0800</bug_when>
    <thetext>Landed in &lt;http://trac.webkit.org/changeset/78438&gt;</thetext>
  </long_desc>
      
          <attachment
              isobsolete="0"
              ispatch="0"
              isprivate="0"
          >
            <attachid>80475</attachid>
            <date>2011-01-28 12:00:54 -0800</date>
            <delta_ts>2011-01-28 12:00:54 -0800</delta_ts>
            <desc>Test case...</desc>
            <filename>test_link_drag_drop.html</filename>
            <type>text/html</type>
            <size>304</size>
            <attacher name="Dawit A.">adawit</attacher>
            
              <data encoding="base64">PGh0bWw+CjxoZWFkPgo8dGl0bGU+VGVzdCBMaW5rIERyYWcgYW5kIERyb3A8L3RpdGxlPgo8L2hl
YWQ+Cjxib2R5Pgo8YSBocmVmPSJodHRwczovL3d3dy5nb29nbGUuY29tL2FjY291bnRzL1NlcnZp
Y2VMb2dpbj9zZXJ2aWNlPW1haWwmcGFzc2l2ZT10cnVlJnJtPWZhbHNlJmNvbnRpbnVlPWh0dHAl
M0ElMkYlMkZtYWlsLmdvb2dsZS5jb20lMkZtYWlsJTJGJTNGdWklM0RodG1sJTI2enklM0RsJmJz
dj1sbHlhNjk0bGUzNnomc2NjPTEmbHRtcGw9ZGVmYXVsdCZsdG1wbGNhY2hlPTIiPkRyYWcgbWU8
L2E+CjwvYm9keT4KPC9odG1sPg==
</data>

          </attachment>
          <attachment
              isobsolete="0"
              ispatch="1"
              isprivate="0"
          >
            <attachid>82235</attachid>
            <date>2011-02-12 09:41:50 -0800</date>
            <delta_ts>2011-02-13 06:23:47 -0800</delta_ts>
            <desc>Patch for review</desc>
            <filename>patch_53320</filename>
            <type>text/plain</type>
            <size>1308</size>
            <attacher name="Aparna Nandyal">aparna.nand</attacher>
            
              <data encoding="base64">ZGlmZiAtLWdpdCBhL1NvdXJjZS9XZWJDb3JlL0NoYW5nZUxvZyBiL1NvdXJjZS9XZWJDb3JlL0No
YW5nZUxvZwppbmRleCBjNWM1OTRjLi43NzI0MWQyIDEwMDY0NAotLS0gYS9Tb3VyY2UvV2ViQ29y
ZS9DaGFuZ2VMb2cKKysrIGIvU291cmNlL1dlYkNvcmUvQ2hhbmdlTG9nC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RHJhZ0RhdGE6OmFzVVJMKEZyYW1l
KiwgRmlsZW5hbWVDb252ZXJzaW9uUG9saWN5IGZpbGVuYW1lUG9saWN5LCBTdHJpbmcqKQogICAg
IGlmICh1cmxzLmlzRW1wdHkoKSkKICAgICAgICAgcmV0dXJuIFN0cmluZygpOwogCi0gICAgcmV0
dXJuIGVuY29kZVdpdGhVUkxFc2NhcGVTZXF1ZW5jZXModXJscy5maXJzdCgpLnRvU3RyaW5nKCkp
OworICAgIHJldHVybiBTdHJpbmcodXJscy5maXJzdCgpLnRvRW5jb2RlZCgpLmNvbnN0RGF0YSgp
KTsKIH0KIAogUGFzc1JlZlB0cjxEb2N1bWVudEZyYWdtZW50PiBEcmFnRGF0YTo6YXNGcmFnbWVu
dChGcmFtZSogZnJhbWUsIFBhc3NSZWZQdHI8UmFuZ2U+LCBib29sLCBib29sJikgY29uc3QK
</data>
<flag name="review"
          id="73880"
          type_id="1"
          status="-"
          setter="kling"
    />
          </attachment>
          <attachment
              isobsolete="0"
              ispatch="1"
              isprivate="0"
          >
            <attachid>82272</attachid>
            <date>2011-02-13 11:45:04 -0800</date>
            <delta_ts>2011-02-13 11:50:00 -0800</delta_ts>
            <desc>Patch with comments implemented</desc>
            <filename>patch_updated_53320</filename>
            <type>text/plain</type>
            <size>1370</size>
            <attacher name="Aparna Nandyal">aparna.nand</attacher>
            
              <data encoding="base64">ZGlmZiAtLWdpdCBhL1NvdXJjZS9XZWJDb3JlL0NoYW5nZUxvZyBiL1NvdXJjZS9XZWJDb3JlL0No
YW5nZUxvZwppbmRleCBjNWM1OTRjLi43NzI0MWQyIDEwMDY0NAotLS0gYS9Tb3VyY2UvV2ViQ29y
ZS9DaGFuZ2VMb2cKKysrIGIvU291cmNlL1dlYkNvcmUvQ2hhbmdlTG9nCkBAIC0xLDMgKzEsMTYg
QEAKKzIwMTEtMDItMTIgIEFwYXJuYSBOYW5keWFsICA8YXBhcm5hLm5hbmRAd2lwcm8uY29tPgor
CisgICAgICAgIFJld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mICh1cmxzLmlzRW1wdHkoKSkKICAgICAgICAgcmV0dXJuIFN0cmluZygpOwogCi0gICAgcmV0
dXJuIGVuY29kZVdpdGhVUkxFc2NhcGVTZXF1ZW5jZXModXJscy5maXJzdCgpLnRvU3RyaW5nKCkp
OworICAgIFFCeXRlQXJyYXkgZW5jb2RlZFVybCA9IHVybHMuZmlyc3QoKS50b0VuY29kZWQoKTsK
KyAgICByZXR1cm4gU3RyaW5nKGVuY29kZWRVcmwuY29uc3REYXRhKCksIGVuY29kZWRVcmwubGVu
Z3RoKCkpOwogfQogCiBQYXNzUmVmUHRyPERvY3VtZW50RnJhZ21lbnQ+IERyYWdEYXRhOjphc0Zy
YWdtZW50KEZyYW1lKiBmcmFtZSwgUGFzc1JlZlB0cjxSYW5nZT4sIGJvb2wsIGJvb2wmKSBjb25z
dAo=
</data>
<flag name="review"
          id="73919"
          type_id="1"
          status="+"
          setter="kling"
    />
    <flag name="commit-queue"
          id="73920"
          type_id="3"
          status="-"
          setter="kling"
    />
          </attachment>
      

    </bug>

</bugzilla>