Webbrowser converts double quotes to %2522
Asked Answered
M

1

7

As explained in the title, whatever I do, I can't get webbrowser to open the URL I want it to open.

I tried escaping the double quotes with \

I tried using %22 in the URL instead of "

No matter what, the end URL ends up effectively turning " into %2522

I know that %25 represents %, which means, somehow " is being turned into %22 first and then the % in that is being turned into %25. Makes no sense, I don't know why it would get processed twice anyway.

Example URL (what I get when I print the variable in python):

https://domain.com/do?q=item:(("abc")+OR+("def")+OR+("ghj"))

What webbrowser opens in Chrome:

https://domain.com/do?q=item:((%2522abc%2522)+OR+(%2522def%2522)+OR+(%2522ghj%2522))

Meunier answered 6/8, 2015 at 23:4 Comment(1)
Got the same problem here. It seems to be a bug in the Python URL handling.Branny
R
8

Your code is URL encoding twice. %2522 is a double encoding of " as the encoding of % is %25.

> decodeURIComponent('%2522')
"%22"
> decodeURIComponent('%22')
"\""
Reformatory answered 7/8, 2015 at 1:28 Comment(1)
The thing is I'm not processing the URL at all. It comes straight from a list and gets appended a string. <!-- language-all: lang-pyton --> urls = appscript.app('Google Chrome').windows.tabs.URL() fresh = [item for sublist in urls for item in sublist]Meunier

© 2022 - 2024 — McMap. All rights reserved.