local file path gets double encoded

67 views
Skip to first unread message

fabia...@web.de

unread,
Oct 7, 2017, 7:21:25 PM10/7/17
to CEF Python
consider this line:
target = pathlib.Path(os.path.join("web - Kopie", "html" ,"main.html")).absolute().as_uri()

Which results in file:///E:/PySideFactory/web%20-%20Kopie/html/main.html - a perfectly valid local uri.

When I pass that to CreateBrowserSync as url then it does not load - in fact what I get is this in console:

Not allowed to load local resource: file:///E://PySideFactory/web%2520-%2520Kopie/html/main.html

The %2520 is a %20 encoded for urls again, resulting in a now invalid path as it is looking for a path with a literal %20 in the folder name.

If I leave out the ".as_uri()" then I get a regex error somewhere in cefpython internally, so I can't just pass the non-uri to cefpython.

How to avoid the double encode?

Czarek Tomczak

unread,
Oct 8, 2017, 2:04:49 AM10/8/17
to CEF Python
This issue seems related:
https://github.com/cztomczak/cefpython/issues/384

You can try replacing "%20" with "+" character.

Otherwise modifications to cefpython source code would be required. You can quickly build cefpython from sources using github prebuilt binaries and test it.

Czarek Tomczak

unread,
Oct 8, 2017, 2:07:23 AM10/8/17
to CEF Python
Are you able to load other local files from disk? The error message "Not allowed to load local resource" sounds like a security issue in Chrome (google it).


On Saturday, October 7, 2017 at 11:21:25 PM UTC, fabian.dill wrote:

fabia...@web.de

unread,
Oct 8, 2017, 6:56:48 AM10/8/17
to CEF Python
Yes I can load other local files. The whole problem started happening when a user of my program put my program into a path that had spaces. My development environment did not have spaces so that bug went unnoticed.

the "web%20-%20Kopie" folder is just there for me to investigate this issue.

I've looked at the github issue. I'll post my 2 cents about that there.

Reply all
Reply to author
Forward
0 new messages