FelisCatus / switchysharp

Automatically exported from code.google.com/p/switchysharp
GNU General Public License v3.0
140 stars 50 forks source link

Display warnings about non-ASCII chars in the PAC script #898

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
I have three proxies defined: two SOCKS for some custom URL patterns and an 
HTTP proxy for all the rest.
The HTTP proxy is defined with a PAC file.

If I set SwitchySharp to use only HTTP proxy, I can use internet; if I enable 
rules and set "Default Rule" to use the HTTP proxy, it doesn't work anymore.

Original issue reported on code.google.com by Dario.Pi...@gmail.com on 17 Mar 2014 at 9:27

GoogleCodeExporter commented 9 years ago
In this case, please upload your SwitchySharp backup file and generated PAC 
file as an attachment here. You can press the "Export Backup" and "Export PAC" 
button (once for each) on the "Import/Export" tab.

Original comment by shyc2...@gmail.com on 17 Mar 2014 at 10:51

GoogleCodeExporter commented 9 years ago
Requeste files

Original comment by Dario.Pi...@gmail.com on 17 Mar 2014 at 10:59

Attachments:

GoogleCodeExporter commented 9 years ago
I think the problem is with the PAC script. Chrome does not like non-ASCII 
chars in PAC scripts for some reason, and sadly your PAC file contains some of 
them in the comments above the line saying "return proxy_yes;".

By extracting the PAC file and modifying it locally, I proved that removing the 
comments can make the AutoSwitch work again. For now, I would suggest you 
follow the same steps:
1. Download the PAC file.
2. Modify it locally and remove the comments.
3. Use the "Import PAC" button under the PAC url field.

It is so sad that Chrome decides just to ignore the whole PAC script silently 
without giving any errors either to the user or the developer, for just one 
non-ASCII character in it. In the future, maybe we can detect non-ASCII chars 
in the generated script and display some kind of warning. But removing them 
automatically could be very, very hard. (Detecting comments? Just force remove 
them under the risk of changing the logic of the PAC script?)

Original comment by shyc2...@gmail.com on 18 Mar 2014 at 5:50

GoogleCodeExporter commented 9 years ago
Ok, I understood the problem and did as you suggested: it seems to work now.
I think that stripping comments could be easy and effective in most situations.

Thank you!

Original comment by Dario.Pi...@gmail.com on 18 Mar 2014 at 10:13

GoogleCodeExporter commented 9 years ago
Stripping the comments would require knowledge about how comments work in JS, 
which in turn requires parsing strings and regex literals (which can contains 
sequences like "//" and "/*" but these sequences do not start comments if 
appearing in strings.) Things would be harder than expected.

Maybe a better way could be replacing non-ASCII chars with their \uxxxx escape 
sequences, which would work everywhere (inside and outside strings).

Original comment by shyc2...@gmail.com on 18 Mar 2014 at 10:25

GoogleCodeExporter commented 9 years ago
Yes, that's another way around. I think it should be easy to find a simple JS 
function/library to make this.

Original comment by Dario.Pi...@gmail.com on 18 Mar 2014 at 10:30

GoogleCodeExporter commented 9 years ago
This feature is supported in 2.x. (All non-ascii chars are automatically 
escaped in 2.x.)

Chrome Web Store Install: http://goo.gl/5kbmZp

Github: https://github.com/FelisCatus/SwitchyOmega/releases

Original comment by shyc2...@gmail.com on 15 Dec 2014 at 2:11

GoogleCodeExporter commented 9 years ago
Confirmed!!

I still was on SwitchyProxy 1.x! I didn't even know there was a different 
extension to download...

Original comment by Dario.Pi...@gmail.com on 15 Dec 2014 at 2:22

GoogleCodeExporter commented 9 years ago
2.x is still beta and will be rolled out to all 1.x users soon.

The extension you just downloaded will become the beta channel once the upgrade 
is done, which means you can get the new features and bug fixes as soon as they 
are ready.

Thanks for trying it out!

Original comment by shyc2...@gmail.com on 15 Dec 2014 at 2:28

GoogleCodeExporter commented 9 years ago
Wait... I don't seem to be able to click on the PAC defined proxy! I can only 
click on "normal" ones, the PAC one has a pink/orange icon and can't be clicked 
in the drop down list...

Original comment by Dario.Pi...@gmail.com on 18 Dec 2014 at 10:14

GoogleCodeExporter commented 9 years ago
Please click on the "Error log" item in the dropdown menu after you try the PAC 
one. I will try to diagnose the problem if you can upload the error log here. 
Thanks for the report!

Original comment by shyc2...@gmail.com on 18 Dec 2014 at 10:45

GoogleCodeExporter commented 9 years ago
ERROR: applyProfile ==> Error: 'pacScript.data' supports only ASCII code(encode 
URLs in Punycode format).
    at Object.callback (chrome-extension://padekgcemlokbadohgkifijomclgjgif/js/omega_target_chromium_extension.min.js:3124:21)
    at safeCallbackApply (extensions::sendRequest:21:15)
    at handleResponse (extensions::sendRequest:73:7)
From previous event:
    at new Promise (chrome-extension://padekgcemlokbadohgkifijomclgjgif/js/omega_target.min.js:1972:37)
    at CustomBindingsObject.setAsync (chrome-extension://padekgcemlokbadohgkifijomclgjgif/js/omega_target_chromium_extension.min.js:3117:12)
    at chrome-extension://padekgcemlokbadohgkifijomclgjgif/js/omega_target_chromium_extension.min.js:3525:30
From previous event:
    at ChromeOptions.applyProfileProxy (chrome-extension://padekgcemlokbadohgkifijomclgjgif/js/omega_target_chromium_extension.min.js:3516:30)
    at ChromeOptions.Options.applyProfile (chrome-extension://padekgcemlokbadohgkifijomclgjgif/js/omega_target.min.js:10858:19)
    at chrome-extension://padekgcemlokbadohgkifijomclgjgif/js/background.js:284:23
From previous event:
    at chrome-extension://padekgcemlokbadohgkifijomclgjgif/js/background.js:283:25
From previous event:
    at new Promise (chrome-extension://padekgcemlokbadohgkifijomclgjgif/js/omega_target.min.js:1972:37)
    at CustomBindingsObject.getAsync (chrome-extension://padekgcemlokbadohgkifijomclgjgif/js/omega_target_chromium_extension.min.js:3117:12)
    at ChromeStorage.get (chrome-extension://padekgcemlokbadohgkifijomclgjgif/js/omega_target_chromium_extension.min.js:4028:25)
    at ChromeOptions.Options (chrome-extension://padekgcemlokbadohgkifijomclgjgif/js/omega_target.min.js:10318:34)
    at new ChromeOptions (chrome-extension://padekgcemlokbadohgkifijomclgjgif/js/omega_target_chromium_extension.min.js:3300:48)
    at chrome-extension://padekgcemlokbadohgkifijomclgjgif/js/background.js:160:13
    at chrome-extension://padekgcemlokbadohgkifijomclgjgif/js/background.js:309:4
ERROR: [1] Unhandled rejection:
 Error: 'pacScript.data' supports only ASCII code(encode URLs in Punycode format).
    at Object.callback (chrome-extension://padekgcemlokbadohgkifijomclgjgif/js/omega_target_chromium_extension.min.js:3124:21)
    at safeCallbackApply (extensions::sendRequest:21:15)
    at handleResponse (extensions::sendRequest:73:7)
From previous event:
    at new Promise (chrome-extension://padekgcemlokbadohgkifijomclgjgif/js/omega_target.min.js:1972:37)
    at CustomBindingsObject.setAsync (chrome-extension://padekgcemlokbadohgkifijomclgjgif/js/omega_target_chromium_extension.min.js:3117:12)
    at chrome-extension://padekgcemlokbadohgkifijomclgjgif/js/omega_target_chromium_extension.min.js:3525:30
From previous event:
    at ChromeOptions.applyProfileProxy (chrome-extension://padekgcemlokbadohgkifijomclgjgif/js/omega_target_chromium_extension.min.js:3516:30)
    at ChromeOptions.Options.applyProfile (chrome-extension://padekgcemlokbadohgkifijomclgjgif/js/omega_target.min.js:10858:19)
    at chrome-extension://padekgcemlokbadohgkifijomclgjgif/js/background.js:284:23
From previous event:
    at chrome-extension://padekgcemlokbadohgkifijomclgjgif/js/background.js:283:25
From previous event:
    at new Promise (chrome-extension://padekgcemlokbadohgkifijomclgjgif/js/omega_target.min.js:1972:37)
    at CustomBindingsObject.getAsync (chrome-extension://padekgcemlokbadohgkifijomclgjgif/js/omega_target_chromium_extension.min.js:3117:12)
    at ChromeStorage.get (chrome-extension://padekgcemlokbadohgkifijomclgjgif/js/omega_target_chromium_extension.min.js:4028:25)
    at ChromeOptions.Options (chrome-extension://padekgcemlokbadohgkifijomclgjgif/js/omega_target.min.js:10318:34)
    at new ChromeOptions (chrome-extension://padekgcemlokbadohgkifijomclgjgif/js/omega_target_chromium_extension.min.js:3300:48)
    at chrome-extension://padekgcemlokbadohgkifijomclgjgif/js/background.js:160:13
    at chrome-extension://padekgcemlokbadohgkifijomclgjgif/js/background.js:309:4

Original comment by Dario.Pi...@gmail.com on 18 Dec 2014 at 10:48

GoogleCodeExporter commented 9 years ago
Oh my... I will try to handle that ASAP.

Original comment by shyc2...@gmail.com on 18 Dec 2014 at 11:41

GoogleCodeExporter commented 9 years ago
Version 2.2.5 has been submitted to Chrome Web Store and should be ready in one 
hour.

Original comment by shyc2...@gmail.com on 18 Dec 2014 at 11:48

GoogleCodeExporter commented 9 years ago
2.2.5 is out. This should fix your issue with the PAC script.

You can update immediately by clicking the "Update Extension"
button in the "Developer mode" section in the extension management page.

Original comment by shyc2...@gmail.com on 18 Dec 2014 at 12:11

GoogleCodeExporter commented 9 years ago
It seems ok now, thank you!

Original comment by Dario.Pi...@gmail.com on 18 Dec 2014 at 1:07