Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WebSearch: add a quoting = none setting to prevent quoting/escaping in URLs altogether #42

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion WebSearch/websearch.ini
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,9 @@
# * "quote": Replace special characters using the '%xx' escape. Letters,
# digits, and the characters '_.-' are never quoted.
# * "quote_plus": Like "quote", but replace spaces by plus signs.
# * Default: args_quoting = auto
# * "none": No special characters are quoted, and the arguments provided by
# the user are inserted into the URL exactly as the user wrote them.
# * Default: quoting = auto
# * You may declare as much search site as you wish.


Expand Down
6 changes: 4 additions & 2 deletions WebSearch/websearch.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,9 @@ def _setup_default_icon(self):

def _url_build(self, url_format, search_terms, quoting='auto', fallback_url=None):
def _quote(fmt_string, search_terms, quoting):
if quoting == 'plus':
if quoting == 'none':
return fmt_string.replace("%s", search_terms)
elif quoting == 'plus':
return fmt_string.replace(
"%s", urllib.parse.quote_plus(search_terms))
else: # if quoting == 'quote':
Expand Down Expand Up @@ -162,7 +164,7 @@ def _read_config(self):
'all': kp.ItemHitHint.KEEPALL,
'site': kp.ItemHitHint.NOARGS,
'none': kp.ItemHitHint.IGNORE}
supported_quoting = ['auto', 'full', 'plus']
supported_quoting = ['auto', 'full', 'plus', 'none']

settings = self.load_settings()

Expand Down