carsonyl / pypac

Find and use proxy auto-config (PAC) files with Python and Requests.
https://pypac.readthedocs.io
Apache License 2.0
71 stars 19 forks source link

import error observed when "let" keyword is used to create a global variable #66

Closed shaahidsk closed 1 year ago

shaahidsk commented 1 year ago

pac file contents has "let" keyword declaring an integer variable.

let test_pac = 0;

Traceback (most recent call last): File "/Users/shaahidahams/Desktop/automation/gvenv/lib/python3.8/site-packages/pypac/parser.py", line 60, in init self._context.evaljs(pac_js) File "/Users/shaahidahams/Desktop/automation/gvenv/lib/python3.8/site-packages/dukpy/evaljs.py", line 57, in evaljs res = _dukpy.eval_string(self, jscode, jsvars) _dukpy.JSRuntimeError: SyntaxError: unterminated statement (line 1) at [anon] (eval:1) internal at [anon] (duk_js_compiler.c:6826) internal During handling of the above exception, another exception occurred:

carsonyl commented 1 year ago

This appears to be a limitation in dukpy, the library pypac uses for JavaScript. See https://github.com/amol-/dukpy/issues/47.

Can you provide an example service and/or PAC file that contains let? Could let be simply replaced with var?

shaahidsk commented 1 year ago

Thanks, @carsonyl . As a workaround I am replacing the "let" keyword with "var" post downloading the pac file. I am just wondering if we have a easy solution fixing in the pypac library, but now I understand that it seems to be a limitation in dukpy, as you pointed.!. This pac file which I am using is an internal service to the organization.