internlm/SWE-Fixer-Train-110K huggingface dataset:
Repository: qutebrowser/qutebrowser

Issue:
Can't enable per-domain settings for https://example.com./
When running `qutebrowser --temp-basedir -s content.javascript.enabled false 'https://travis-ci.com./'` and pressing `tsh`, JavaScript is still not allowed for Travis CI.

This was introduced in 8b822e40e3243f9679244cfcdf0e7abd1de0289f / #4707 - cc @jgkamat 


Discussion:
**Version info**:
- 1.9.0 is affected
- 1.8.2 is not affected

**Does the bug happen if you start with `--temp-basedir`?**:
yes

**How to reproduce**
1. visit https://travis-ci.com/
2. observe that the `<noscript>` block is show depending on the value of content.javascript.enabled, which can be toggled for this site by typing `tsh`
3. visit https://travis-ci.com./
4. observe that typing `tsh` has no effect
5. notice that the setting for https://travis-ci.com./ is applied to https://travis-ci.com/ instead. 


Resolving patch:
diff --git a/qutebrowser/config/configutils.py b/qutebrowser/config/configutils.py
--- a/qutebrowser/config/configutils.py
+++ b/qutebrowser/config/configutils.py
@@ -225,7 +225,9 @@ def get_for_url(self, url: QUrl = None, *,
             return self._get_fallback(fallback)
 
         candidates = []  # type: typing.List[ScopedValue]
-        widened_hosts = _widened_hostnames(url.host())
+        # Urls trailing with '.' are equivalent to non-trailing types.
+        # urlutils strips them, so in order to match we will need to as well.
+        widened_hosts = _widened_hostnames(url.host().rstrip('.'))
         # We must check the 'None' key as well, in case any patterns that
         # did not have a domain match.
         for host in itertools.chain(widened_hosts, [None]):


Test patch:
diff --git a/tests/unit/config/test_configutils.py b/tests/unit/config/test_configutils.py
--- a/tests/unit/config/test_configutils.py
+++ b/tests/unit/config/test_configutils.py
@@ -229,6 +229,19 @@ def test_get_equivalent_patterns(empty_values):
     assert empty_values.get_for_pattern(pat2) == 'pat2 value'
 
 
+def test_get_trailing_url(values):
+    other_pattern = urlmatch.UrlPattern('https://www.example.org./')
+    values.add('example.org value', other_pattern)
+    assert values.get_for_url() == 'global value'
+    example_com = QUrl('https://www.example.com/')
+    example_org = QUrl('https://www.example.org./')
+    example_org_2 = QUrl('https://www.example.org/')
+    assert values.get_for_url(example_com) == 'example value'
+    assert (values.get_for_url(example_org) ==
+            values.get_for_url(example_org_2) ==
+            'example.org value')
+
+
 @pytest.mark.parametrize('func', [
     pytest.param(lambda values, pattern:
                  values.add(None, pattern),
Repository: qutebrowser/qutebrowser

Issue:
Have option to disable Mouse 4 and Mouse 5 from jumping forward and back through tab history.
When using Mouse 4 or Mouse 5 as a global hotkey for another application, for example a voice chat program such as Discord or Mumble using either button as push to talk, qutebrowser still receives the button press and goes forward and backwards through history while focused. Some way to disable Mouse 4 and Mouse 5 from being used by qutebrowser would be cool.


Discussion:

Resolving patch:
diff --git a/qutebrowser/browser/eventfilter.py b/qutebrowser/browser/eventfilter.py
--- a/qutebrowser/browser/eventfilter.py
+++ b/qutebrowser/browser/eventfilter.py
@@ -116,7 +116,7 @@ def _handle_mouse_press(self, e):
         Return:
             True if the event should be filtered, False otherwise.
         """
-        is_rocker_gesture = (config.val.input.rocker_gestures and
+        is_rocker_gesture = (config.val.input.mouse.rocker_gestures and
                              e.buttons() == Qt.LeftButton | Qt.RightButton)
 
         if e.button() in [Qt.XButton1, Qt.XButton2] or is_rocker_gesture:
@@ -204,7 +204,7 @@ def _handle_context_menu(self, _e):
         Return:
             True if the event should be filtered, False otherwise.
         """
-        return config.val.input.rocker_gestures
+        return config.val.input.mouse.rocker_gestures
 
     def _handle_key_release(self, e):
         """Ignore repeated key release events going to the website.
@@ -276,6 +276,11 @@ def _mousepress_backforward(self, e):
         Return:
             True if the event should be filtered, False otherwise.
         """
+        if (not config.val.input.mouse.back_forward_buttons and
+                e.button() in [Qt.XButton1, Qt.XButton2]):
+            # Back and forward on mice are disabled
+            return
+
         if e.button() in [Qt.XButton1, Qt.LeftButton]:
             # Back button on mice which have it, or rocker gesture
             if self._tab.history.can_go_back():


Test patch:
Repository: qutebrowser/qutebrowser

Issue:
Running asciidoc2html.py from outside folder
**Version info**:
qutebrowser v1.13.0                            
Git commit: 6e9f24bc8-dirty on master (2020-07-01 15:34:57 +0200)
Backend: QtWebEngine (Chromium 80.0.3987.163)
Qt: 5.15.0  

**Does the bug happen if you start with `--temp-basedir`?**:

**Description**
If one runs `scripts/asciidoc2html.py` (or `script/mkvenv.py`) outside of the folder, this fails since the path are not relative to the root of the repo.

**How to reproduce**
Run `scripts/mkvenv.py` from outside the repo root.



Discussion:

Resolving patch:
diff --git a/scripts/asciidoc2html.py b/scripts/asciidoc2html.py
--- a/scripts/asciidoc2html.py
+++ b/scripts/asciidoc2html.py
@@ -35,7 +35,8 @@
 
 from scripts import utils
 
-DOC_DIR = pathlib.Path("qutebrowser/html/doc")
+REPO_ROOT = pathlib.Path(__file__).parent.parent
+DOC_DIR = REPO_ROOT / 'qutebrowser' / 'html' / 'doc'
 
 
 class AsciiDoc:
@@ -79,9 +80,9 @@ def build(self) -> None:
 
     def _build_docs(self) -> None:
         """Render .asciidoc files to .html sites."""
-        files = [(pathlib.Path('doc/{}.asciidoc'.format(f)),
+        files = [(REPO_ROOT / 'doc' / '{}.asciidoc'.format(f)),
                   DOC_DIR / (f + ".html")) for f in self.FILES]
-        for src in pathlib.Path('doc/help/').glob('*.asciidoc'):
+        for src in (REPO_ROOT / 'doc' / 'help').glob('*.asciidoc'):
             dst = DOC_DIR / (src.stem + ".html")
             files.append((src, dst))
 
@@ -111,7 +112,7 @@ def _copy_images(self) -> None:
         dst_path = DOC_DIR / 'img'
         dst_path.mkdir(exist_ok=True)
         for filename in ['cheatsheet-big.png', 'cheatsheet-small.png']:
-            src = pathlib.Path('doc') / 'img' / filename
+            src = REPO_ROOT / 'doc' / 'img' / filename
             dst = dst_path / filename
             shutil.copy(str(src), str(dst))
 
@@ -125,7 +126,7 @@ def _build_website_file(self, root: pathlib.Path, filename: str) -> None:
 
         assert self._tempdir is not None    # for mypy
         modified_src = self._tempdir / src.name
-        shutil.copy('www/header.asciidoc', modified_src)
+        shutil.copy(str(REPO_ROOT / 'www' / 'header.asciidoc'), modified_src)
 
         outfp = io.StringIO()
 
@@ -181,7 +182,7 @@ def _build_website_file(self, root: pathlib.Path, filename: str) -> None:
 
     def _build_website(self) -> None:
         """Prepare and build the website."""
-        theme_file = (pathlib.Path('www') / 'qute.css').resolve()
+        theme_file = REPO_ROOT / 'www' / 'qute.css'
         assert self._themedir is not None   # for mypy
         shutil.copy(theme_file, self._themedir)
 
@@ -205,7 +206,7 @@ def _build_website(self) -> None:
 
         for dst, link_name in [
                 ('README.html', 'index.html'),
-                ((pathlib.Path('doc') / 'quickstart.html'),
+                ((REPO_ROOT / 'doc' / 'quickstart.html'),
                  'quickstart.html')]:
             assert isinstance(dst, (str, pathlib.Path))    # for mypy
             try:


Test patch:
Repository: qutebrowser/qutebrowser

Issue:
Port completion.models.listcategory to QRegularExpression
In `qutebrowser/completion/models/listcategory.py`, we use `QRegExp`, which is going to be removed in Qt 6:

```python
        rx = QRegExp(val, Qt.CaseInsensitive)
        self.setFilterRegExp(rx)
```

We should instead [port](https://doc-snapshots.qt.io/qt6-dev/qtcore-changes-qt6.html#regular-expression-classes) this to use [QRegularExpression](https://doc.qt.io/qt-5/qregularexpression.html) (or, perhaps, Python's `re`?) instead.

~~(Also, we should probably call `qtutils.ensure_valid(rx)`)~~ (done in `master` already)

cc @rcorre 


Discussion:

Resolving patch:
diff --git a/qutebrowser/completion/models/listcategory.py b/qutebrowser/completion/models/listcategory.py
--- a/qutebrowser/completion/models/listcategory.py
+++ b/qutebrowser/completion/models/listcategory.py
@@ -22,7 +22,7 @@
 import re
 from typing import Iterable, Tuple
 
-from PyQt5.QtCore import Qt, QSortFilterProxyModel, QRegExp
+from PyQt5.QtCore import QSortFilterProxyModel, QRegularExpression
 from PyQt5.QtGui import QStandardItem, QStandardItemModel
 from PyQt5.QtWidgets import QWidget
 
@@ -63,9 +63,9 @@ def set_pattern(self, val):
         val = re.sub(r' +', r' ', val)  # See #1919
         val = re.escape(val)
         val = val.replace(r'\ ', '.*')
-        rx = QRegExp(val, Qt.CaseInsensitive)
+        rx = QRegularExpression(val, QRegularExpression.CaseInsensitiveOption)
         qtutils.ensure_valid(rx)
-        self.setFilterRegExp(rx)
+        self.setFilterRegularExpression(rx)
         self.invalidate()
         sortcol = 0
         self.sort(sortcol)


Test patch:
Repository: qutebrowser/qutebrowser

Issue:
Error page does not fully work without JS
When a page cannot load due to an error (e.g., renderer process killed), an error page with the text "Unable to load page" is displayed with the URL of the page that I tried to load and a button to "Try again"; however, clicking on this button has no effect. Further inspection reveals that this button relies on JavaScript (I have `content.javascript.enabled` set to false by default).

As a small quality of life improvement, would it be feasible to change the button to a simple link that would work without JS? I would be happy to open a pull request with this change (it seems that this would only entail changing a few lines in [`error.html`](https://github.com/qutebrowser/qutebrowser/blob/master/qutebrowser/html/error.html)); I just wanted to check first if that would be a good idea.


Discussion:
Hmm, this makes me wonder why this even was using JS in the first place...

When the error pages were added in e56ed54102f4545f88a11d78d9fcb4b252385cab, we called `location.reload()` instead. With 1fcce6d87cdcd11cb9becd2a022fce028110a639 I changed this to use `location.href = url` (with a fixup in 5c367e7ab24bb3b885afe0eb7c1c95ad0caf2634, and some more follow-ups with e81f070a7929e6c7a1f4ff097c7106a5d256d90e and d2e5eae7fb32a8ddd63f67357b972476c399a6a1).

In hindsight, a normal link makes perfect sense, and I don't see why this should be using JS to be honest... So go ahead!
Oh, also note that you can probably drop `self.filters['js_string_escape'] = javascript.string_escape` as well as the associated `javascript` import from `qutebrowser/utils/jinja.py` after that change too.

Resolving patch:
diff --git a/qutebrowser/utils/jinja.py b/qutebrowser/utils/jinja.py
--- a/qutebrowser/utils/jinja.py
+++ b/qutebrowser/utils/jinja.py
@@ -31,7 +31,7 @@
 import jinja2.nodes
 from PyQt5.QtCore import QUrl
 
-from qutebrowser.utils import utils, urlutils, log, qtutils, javascript
+from qutebrowser.utils import utils, urlutils, log, qtutils
 from qutebrowser.misc import debugcachestats
 
 
@@ -95,7 +95,6 @@ def __init__(self) -> None:
         self.globals['file_url'] = urlutils.file_url
         self.globals['data_url'] = self._data_url
         self.globals['qcolor_to_qsscolor'] = qtutils.qcolor_to_qsscolor
-        self.filters['js_string_escape'] = javascript.string_escape
         self._autoescape = True
 
     @contextlib.contextmanager


Test patch:
Repository: qutebrowser/qutebrowser

Issue:
open in new tab by default if current tab is pinned.
If the current tab is pinned, then using ':open' gives a message 'tab is pinned'
It would be useful to have an option to make 'open' default to opening new tab when the current tab is pinned, rather than throwing an error.


Discussion:
I guess that makes sense. I'm not even sure if it needs to be an option, I'd be fine with making it the default.
Can I try to work on it if anybody else is not.I was thinking I could start contributing from this issue.

@pspiagicw Please go ahead! The relevant code is in `openurl` in `qutebrowser/browser/commands.py`.

Resolving patch:
diff --git a/qutebrowser/browser/commands.py b/qutebrowser/browser/commands.py
--- a/qutebrowser/browser/commands.py
+++ b/qutebrowser/browser/commands.py
@@ -329,7 +329,9 @@ def openurl(self, url=None, related=False,
                         # Explicit count with a tab that doesn't exist.
                         return
                 elif curtab.navigation_blocked():
-                    message.info("Tab is pinned!")
+                    message.info("Tab is pinned! Opening in new tab")
+                    self._tabbed_browser.tabopen(cur_url)
+
                 else:
                     curtab.load_url(cur_url)
 


Test patch:
diff --git a/tests/end2end/features/sessions.feature b/tests/end2end/features/sessions.feature
--- a/tests/end2end/features/sessions.feature
+++ b/tests/end2end/features/sessions.feature
@@ -395,9 +395,10 @@ Feature: Saving and loading sessions
       And I run :session-load -c pin_session
       And I wait until data/numbers/3.txt is loaded
       And I run :tab-focus 2
-      And I run :open hello world
-      Then the message "Tab is pinned!" should be shown
+      And I run :open data/numbers/4.txt
+      Then the message "Tab is pinned! Opening in new tab" should be shown
       And the following tabs should be open:
         - data/numbers/1.txt
         - data/numbers/2.txt (active) (pinned)
+        - data/numbers/4.txt
         - data/numbers/3.txt
diff --git a/tests/end2end/features/tabs.feature b/tests/end2end/features/tabs.feature
--- a/tests/end2end/features/tabs.feature
+++ b/tests/end2end/features/tabs.feature
@@ -1534,10 +1534,11 @@ Feature: Tab management
     Scenario: :tab-pin open url
         When I open data/numbers/1.txt
         And I run :tab-pin
-        And I open data/numbers/2.txt without waiting
-        Then the message "Tab is pinned!" should be shown
+        And I open data/numbers/2.txt
+        Then the message "Tab is pinned! Opening in new tab" should be shown
         And the following tabs should be open:
             - data/numbers/1.txt (active) (pinned)
+            - data/numbers/2.txt
 
     Scenario: :tab-pin open url with tabs.pinned.frozen = false
         When I set tabs.pinned.frozen to false
Repository: qutebrowser/qutebrowser

Issue:
ValueError in _implied_cmd with invalid set-cmd-text binding
When doing `:` after `:bind x set-cmd-text` on v2.2.1:

```pytb
Traceback (most recent call last):
  File "/home/florian/proj/qutebrowser/git/qutebrowser/completion/completer.py", line 277, in _update_completion
    model = func(*args, info=info)
  File "/home/florian/proj/qutebrowser/git/qutebrowser/completion/models/miscmodels.py", line 35, in command
    cmdlist = util.get_cmd_completions(info, include_aliases=True,
  File "/home/florian/proj/qutebrowser/git/qutebrowser/completion/models/util.py", line 44, in get_cmd_completions
    cmd_to_keys = info.keyconf.get_reverse_bindings_for('normal')
  File "/home/florian/proj/qutebrowser/git/qutebrowser/config/config.py", line 195, in get_reverse_bindings_for
    cmd = self._implied_cmd(cmdtext.strip())
  File "/home/florian/proj/qutebrowser/git/qutebrowser/config/config.py", line 176, in _implied_cmd
    *flags, cmd = result.args
ValueError: not enough values to unpack (expected at least 1, got 0)
```

cc @rcorre 


Discussion:

Resolving patch:
diff --git a/qutebrowser/config/config.py b/qutebrowser/config/config.py
--- a/qutebrowser/config/config.py
+++ b/qutebrowser/config/config.py
@@ -173,6 +173,8 @@ def _implied_cmd(self, cmdline: str) -> Optional[str]:
         result = results[0]
         if result.cmd.name != "set-cmd-text":
             return cmdline
+        if not result.args:
+            return None  # doesn't look like this sets a command
         *flags, cmd = result.args
         if "-a" in flags or "--append" in flags or not cmd.startswith(":"):
             return None  # doesn't look like this sets a command


Test patch:
diff --git a/tests/unit/config/test_config.py b/tests/unit/config/test_config.py
--- a/tests/unit/config/test_config.py
+++ b/tests/unit/config/test_config.py
@@ -211,6 +211,7 @@ def test_get_command_default(self, key_config_stub, config_stub):
                 "a": "set-cmd-text no_leading_colon",
                 "b": "set-cmd-text -s -a :skip_cuz_append",
                 "c": "set-cmd-text --append :skip_cuz_append",
+                "x": "set-cmd-text",
             },
             {
                 "open": ["o"],
Repository: qutebrowser/qutebrowser

Issue:
macos: can't scroll through tabbar
**Version info**:
<!-- Please copy the first block from :version, not just the qutebrowser version -->
qutebrowser v2.0.2
Git commit: f11cdd0bf on HEAD (2021-02-04 10:19:33 +0100)
Backend: QtWebEngine (Chromium 83.0.4103.122)
Qt: 5.15.2

**Does the bug happen if you start with `--temp-basedir`?**:
yes

**Description**
running the scrollwheel with the mouse hovered over the tabbar on macos doesn't cycle through tabs

**How to reproduce**
NA/description



Discussion:
I think Qt does some special stuff to use macOS' tab implementation for its `QTabBar`, which might be causing this. I'll try to take a closer look sometime soon, haven't gotten around to it yet.
I can reproduce - it looks like this is deliberately ignored in Qt:

- [[QTBUG-8428] wheel event should not change active tab - Qt Bug Tracker](https://bugreports.qt.io/browse/QTBUG-8428)
- [QTabBar: Disable wheel events on Mac (Ifab663b4) · Gerrit Code Review](https://codereview.qt-project.org/c/qt/qtbase/+/109523)

Here's the Qt 5.15.2 doing so: https://github.com/qt/qtbase/blob/v5.15.2/src/widgets/widgets/qtabbar.cpp#L2325-L2352
It looks like Qt 6 made it configurable: https://github.com/qt/qtbase/blob/v6.1.0-alpha1/src/widgets/widgets/qtabbar.cpp#L2363-L2386 ([control scrolling of QTabBar using StyleHint (I99eeb5a1) · Gerrit Code Review](https://codereview.qt-project.org/c/qt/qtbase/+/327746)).

We already override `wheelEvent` for the `tabs.mousewheel_switching` option, so we might as well just reimplement those couple of lines of logic for macOS instead of relying on the Qt implementation...

Resolving patch:
diff --git a/qutebrowser/mainwindow/tabwidget.py b/qutebrowser/mainwindow/tabwidget.py
--- a/qutebrowser/mainwindow/tabwidget.py
+++ b/qutebrowser/mainwindow/tabwidget.py
@@ -705,7 +705,21 @@ def wheelEvent(self, e):
             e: The QWheelEvent
         """
         if config.val.tabs.mousewheel_switching:
-            super().wheelEvent(e)
+            if utils.is_mac:
+                # WORKAROUND for this not being customizable until Qt 6:
+                # https://codereview.qt-project.org/c/qt/qtbase/+/327746
+                index = self.currentIndex()
+                if index == -1:
+                    return
+                dx = e.angleDelta().x()
+                dy = e.angleDelta().y()
+                delta = dx if abs(dx) > abs(dy) else dy
+                offset = -1 if delta > 0 else 1
+                index += offset
+                if 0 <= index < self.count():
+                    self.setCurrentIndex(index)
+            else:
+                super().wheelEvent(e)
         else:
             tabbed_browser = objreg.get('tabbed-browser', scope='window',
                                         window=self._win_id)


Test patch:
Repository: qutebrowser/qutebrowser

Issue:
FR: don't download local files, open them with their default program.
After clicking on a file that cannot be opened by qutebrowser on a local directory page (`file://` URLs), `qutebrowser` should not start a download for that local file, but instead try to open it with the default handler.

IRC conversation:
```
17:29 <emanuele6> if i'm viewing a local directory in qutebrowser
17:29 <emanuele6> and i click on a file that qutebrowser can't open, qutebrowser tries to download it
17:29 <emanuele6> e.g. mkv files
17:29 <emanuele6> is there a way to tell qutebrowser to open it in mpv?
17:32 <The-Compiler> emanuele6: nope, that behavior is coming from the underlying Chromium
17:33 <The-Compiler> emanuele6: might make sense for qutebrowser to not accept the download and open the file:/// URL with the default handler though - mind opening an issue?
```


Discussion:
Note that we should double-check that the download request is really coming from a `file:` URL before doing this.

Resolving patch:
diff --git a/qutebrowser/browser/webengine/webenginedownloads.py b/qutebrowser/browser/webengine/webenginedownloads.py
--- a/qutebrowser/browser/webengine/webenginedownloads.py
+++ b/qutebrowser/browser/webengine/webenginedownloads.py
@@ -251,6 +251,7 @@ def handle_download(self, qt_item):
         qt_filename = os.path.basename(qt_item.path())   # FIXME use 5.14 API
         mime_type = qt_item.mimeType()
         url = qt_item.url()
+        origin = qt_item.page().url() if qt_item.page() else QUrl()
 
         # WORKAROUND for https://bugreports.qt.io/browse/QTBUG-90355
         if version.qtwebengine_versions().webengine >= utils.VersionNumber(5, 15, 3):
@@ -292,12 +293,16 @@ def handle_download(self, qt_item):
             download.set_target(target)
             return
 
+        if url.scheme() == "file" and origin.isValid() and origin.scheme() == "file":
+            utils.open_file(url.toLocalFile())
+            qt_item.cancel()
+            return
+
         # Ask the user for a filename - needs to be blocking!
         question = downloads.get_filename_question(
             suggested_filename=suggested_filename, url=qt_item.url(),
             parent=self)
         self._init_filename_question(question, download)
-
         message.global_bridge.ask(question, blocking=True)
         # The filename is set via the question.answered signal, connected in
         # _init_filename_question.


Test patch: