Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-10146

QUrl::addQueryItem(key, value) performs invalid escaping for values that contain a '+'

    XMLWordPrintable

Details

    • Bug
    • Resolution: Invalid
    • Not Evaluated
    • None
    • 4.6.2
    • Core: I/O, Network
    • None
    • Linux

    Description

      After the following call on a QUrl instance url:

      url.addQueryItem("test", "plus+and space");

      one would expect the resulting url instance to procude an encoded query like this:

      ...&test=plus%2Band%20space

      Or, following the convention to encode spaces as '+' in encoded queries, one might expect that:

      ...&test=plus%2Band+space

      However, the current QUrl implementation does none of the above. Instead, it generates:

      ...&test=plus+and%20space

      This is wrong, and most web applications will decode that test parameter as "plus and space". So the QUrl::addQueryItem() method effectively converts all '+' characters to spaces.

      Additional note: The method QUrl::toPercentEncoding() works correctly in this regard. So the following code:

      url.addEncodedQueryItem("id", QUrl::toPercentEncoding("plus+and space"));

      will produce a correct result:

      ...&test=plus%2Band%20space

      Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            tmacieir Thiago Macieira (closed Nokia identity) (Inactive)
            vog Volker Grabsch
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes