| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -119,6 +119,15 @@ def test_open_bad_new_parameter(self): | |||
| 119 | 119 | arguments=[URL], | |
| 120 | 120 | kw=dict(new=999)) | |
| 121 | 121 | ||
| 122 | + def test_reject_action_dash_prefixes(self): | ||
| 123 | + browser = self.browser_class(name=CMD_NAME) | ||
| 124 | + with self.assertRaises(ValueError): | ||
| 125 | + browser.open('%action--incognito') | ||
| 126 | + # new=1: action is "--new-window", so "%action" itself expands to | ||
| 127 | + # a dash-prefixed flag even with no dash in the original URL. | ||
| 128 | + with self.assertRaises(ValueError): | ||
| 129 | + browser.open('%action', new=1) | ||
| 130 | + | ||
| 122 | 131 | ||
| 123 | 132 | class EdgeCommandTest(CommandTestMixin, unittest.TestCase): | |
| 124 | 133 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -274,7 +274,6 @@ def _invoke(self, args, remote, autoraise, url=None): | |||
| 274 | 274 | ||
| 275 | 275 | def open(self, url, new=0, autoraise=True): | |
| 276 | 276 | sys.audit("webbrowser.open", url) | |
| 277 | - self._check_url(url) | ||
| 278 | 277 | if new == 0: | |
| 279 | 278 | action = self.remote_action | |
| 280 | 279 | elif new == 1: | |
@@ -288,7 +287,9 @@ def open(self, url, new=0, autoraise=True): | |||
| 288 | 287 | raise Error("Bad 'new' parameter to open(); " | |
| 289 | 288 | f"expected 0, 1, or 2, got {new}") | |
| 290 | 289 | ||
| 291 | - args = [arg.replace("%s", url).replace("%action", action) | ||
| 290 | + self._check_url(url.replace("%action", action)) | ||
| 291 | + | ||
| 292 | + args = [arg.replace("%action", action).replace("%s", url) | ||
| 292 | 293 | for arg in self.remote_args] | |
| 293 | 294 | args = [arg for arg in args if arg] | |
| 294 | 295 | success = self._invoke(args, True, autoraise, url) | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,2 @@ | |||
| 1 | + A bypass in :mod:`webbrowser` allowed URLs prefixed with ``%action`` to pass | ||
| 2 | + the dash-prefix safety check. | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments