Repository: qutebrowser/qutebrowser

Issue:
Can't yank Qt codereview URL
When I'm on [this page](https://codereview.qt-project.org/gitweb?p=qt/qtbase.git;a=patch;h=b3b8b1a4b4623b344f3e50644d4b662a572ec139) I can't yank the URL in a format e.g. wget understands, because the `=` get converted to `%3D`, even with `:yank pretty-url`.



Discussion:
`:yank pretty-url` decodes the first `=`, but not the other, which are attributed a special meaning. The problem is that the URL uses `;` instead of `&` as a separator in the query string.

FWIW, both curl and wget understand the fully-encoded URL:

```
$ curl -O "https://codereview.qt-project.org/gitweb?p=qt/qtbase.git;a%3Dpatch;h%3Db3b8b1a4b4623b344f3e50644d4b662a572ec139"
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100 43590    0 43590    0     0  14466      0 --:--:--  0:00:03 --:--:-- 14472
```

Sorry, I wasn't specific enough there - they understand the URL, but they load the index page and not the patch file I get when opening the URL in qutebrowser.

Changing the `=` to `%3D` after the `?` changes the meaning of the URL, what separator is used does not matter.

The modification is introduced in `browser/commands.py:685-689` to support the `general->yank-ignored-url-parameters` option.


Resolving patch:
diff --git a/qutebrowser/browser/commands.py b/qutebrowser/browser/commands.py
--- a/qutebrowser/browser/commands.py
+++ b/qutebrowser/browser/commands.py
@@ -682,7 +682,11 @@ def _yank_url(self, what):
         else:
             flags |= QUrl.FullyEncoded
         url = QUrl(self._current_url())
-        url_query = QUrlQuery(url)
+        url_query = QUrlQuery()
+        url_query_str = url.query()
+        if '&' not in url_query_str and ';' in url_query_str:
+            url_query.setQueryDelimiters('=', ';')
+        url_query.setQuery(url_query_str)
         for key in dict(url_query.queryItems()):
             if key in config.get('general', 'yank-ignored-url-parameters'):
                 url_query.removeQueryItem(key)


Test patch:
diff --git a/tests/end2end/features/yankpaste.feature b/tests/end2end/features/yankpaste.feature
--- a/tests/end2end/features/yankpaste.feature
+++ b/tests/end2end/features/yankpaste.feature
@@ -57,6 +57,24 @@ Feature: Yanking and pasting.
         Then the message "Yanked URL to clipboard: http://localhost:(port)/data/title with spaces.html" should be shown
         And the clipboard should contain "http://localhost:(port)/data/title with spaces.html"
 
+	Scenario: Yanking URL that has = and & in its query string
+		When I open data/title.html?a=b&c=d
+		And I run :yank
+		Then the message "Yanked URL to clipboard: http://localhost:(port)/data/title.html?a=b&c=d" should be shown
+		And the clipboard should contain "http://localhost:(port)/data/title.html?a=b&c=d"
+
+	Scenario: Yanking URL that has = and ; in its query string
+		When I open data/title.html?a=b;c=d
+		And I run :yank
+		Then the message "Yanked URL to clipboard: http://localhost:(port)/data/title.html?a=b;c=d" should be shown
+		And the clipboard should contain "http://localhost:(port)/data/title.html?a=b;c=d"
+
+	Scenario: Yanking URL with both & and ; in its query string
+		When I open data/title.html?a;b&c=d
+		And I run :yank
+		Then the message "Yanked URL to clipboard: http://localhost:(port)/data/title.html?a;b&c=d" should be shown
+		And the clipboard should contain "http://localhost:(port)/data/title.html?a;b&c=d"
+
     #### {clipboard} and {primary}
 
     Scenario: Pasting a URL