Fix _make_sizzle_string

The github action runs on python 3.7. From the python docs:
```
Changed in version 3.7: Only characters that can have special meaning in a regular expression are escaped. As a result, '!', '"', '%', "'", ',', '/', ':', ';', '<', '=', '>', '@', and "`" are no longer escaped.
```
This commit is contained in:
mvdbeek
2020-11-22 18:44:33 +01:00
parent 1bb1b1da18
commit bdc3ef7001
+4 -6
View File
@@ -1,6 +1,6 @@
"""Utilities for using sizzle (jQuery-style) selectors with Selenium."""
import re
import json
from selenium.common.exceptions import NoSuchElementException
from selenium.webdriver.support.ui import WebDriverWait
@@ -119,11 +119,9 @@ def _is_sizzle_loaded(driver):
def _make_sizzle_string(sizzle_selector):
try:
selector = sizzle_selector.decode("utf-8")
except (AttributeError, UnicodeEncodeError):
selector = sizzle_selector
return "return Sizzle(\"{selector}\");".format(selector=re.escape(selector))
# Use json.dumps to escape quotes
selector = json.dumps(sizzle_selector)
return f"return Sizzle({selector});"
__all__ = (