bantya / Keypirinha-EasySearch

Keypirinha plugin for faster web searching!
MIT License
24 stars 5 forks source link

Output in browser presented in quotes #8

Open Davix-Pixie opened 3 years ago

Davix-Pixie commented 3 years ago

Issue: When searching for more than one word with space between, easysearch/ Keypirinha outputs incorrect url which leads to

Examples: Definition: [engines] g = Google https://www.google.com/search?q={q}

Input 1: Keypirihna: g this is an example
Output 1: msedge: ULR: http://%22https//www.google.com/search?q=this%20is%20an%20example%22

Input 2: Keypirihna: g example
Output 2- OK: https://www.google.com/search?q=example

Microsoft Edge Version: 86.0.622.69 (Official build) (64-bit)

(#. Note:

  1. this issue was reported to be disappeared by another user in keypirinha 2.26 but it seems to persist even now

  2. at first multi word search used to work like a charm.. but now I think due to some changes in the settings of either the browser, or easysearch this no longer works as intended.

  3. either way the google searches use "+" Therefore, an option to how to handle spaces in argument to be included is a must)

(#. not a developer or used to github, pardon for any unfamiliarity in communication)

phu54321 commented 3 years ago

This seems to be edge-specific issue. Edge doesn't like spaces in URL.

You can fix this by changing https://github.com/bantya/Keypirinha-EasySearch/blob/aa6cb32a4a980a822f7cec8d14eb5394d69d50e1/src/easysearch.py#L91 to line below

                    target = target.strip().format(q = term.strip().replace(' ', '%20'))

To fix this yourself,

1) Rename EasySearch.keypirinha-package to EasySearch.zip 2) Open that with your favorite zip viewer 3) Patch easysearch.py 4) Undo rename at (1).

groenmj commented 3 years ago

This seems to be edge-specific issue. Edge doesn't like spaces in URL.

Maybe the issue does not show with other browsers, but according to RFC 1738 spaces or "unsafe" characters and must be encoded.

You can fix this by changing

https://github.com/bantya/Keypirinha-EasySearch/blob/aa6cb32a4a980a822f7cec8d14eb5394d69d50e1/src/easysearch.py#L91

to line below

                    target = target.strip().format(q = term.strip().replace(' ', '%20'))

This properly encodes spaces, but there are many more "unsafe" characters.

@TakahiroSato provided a better solution relying on urllib.parse.quote. See his PR #5 . You can download the fixed package from the dev-branch in his fork.

--Mark