mirror of
https://github.com/zero-peak/ZeroOmega.git
synced 2025-02-02 02:58:13 -05:00
Escape all non-ascii chars in generated PAC script.
This commit is contained in:
parent
4c65b47860
commit
a008e492b0
@ -8,7 +8,8 @@ module.exports =
|
|||||||
str.replace /[\u0080-\uffff]/g, (char) ->
|
str.replace /[\u0080-\uffff]/g, (char) ->
|
||||||
hex = char.charCodeAt(0).toString(16)
|
hex = char.charCodeAt(0).toString(16)
|
||||||
result = '\\u'
|
result = '\\u'
|
||||||
result += '0' for _ in [hex.length..4]
|
result += '0' for _ in [hex.length...4]
|
||||||
|
result += hex
|
||||||
return result
|
return result
|
||||||
|
|
||||||
compress: (ast) ->
|
compress: (ast) ->
|
||||||
|
@ -6,7 +6,9 @@ chromeApiPromisifer = (originalMethod) ->
|
|||||||
new Promise (resolve, reject) =>
|
new Promise (resolve, reject) =>
|
||||||
callback = (callbackArgs...) ->
|
callback = (callbackArgs...) ->
|
||||||
if chrome.runtime.lastError?
|
if chrome.runtime.lastError?
|
||||||
return reject(chrome.runtime.lastError)
|
error = new Error(chrome.runtime.lastError.message)
|
||||||
|
error.original = chrome.runtime.lastError
|
||||||
|
return reject(error)
|
||||||
if callbackArgs.length <= 1
|
if callbackArgs.length <= 1
|
||||||
resolve(callbackArgs[0])
|
resolve(callbackArgs[0])
|
||||||
else
|
else
|
||||||
|
@ -135,7 +135,8 @@ class ChromeOptions extends OmegaTarget.Options
|
|||||||
data: null
|
data: null
|
||||||
mandatory: true
|
mandatory: true
|
||||||
setPacScript = @pacForProfile(profile).then (script) ->
|
setPacScript = @pacForProfile(profile).then (script) ->
|
||||||
profileName = JSON.stringify(profile.name).replace(/\*/g, '\\u002a')
|
profileName = OmegaPac.PacGenerator.ascii(JSON.stringify(profile.name))
|
||||||
|
profileName = profileName.replace(/\*/g, '\\u002a')
|
||||||
profileName = profileName.replace(/\\/g, '\\u002f')
|
profileName = profileName.replace(/\\/g, '\\u002f')
|
||||||
prefix = "/*OmegaProfile*#{profileName}*#{profile.revision}*/"
|
prefix = "/*OmegaProfile*#{profileName}*#{profile.revision}*/"
|
||||||
config['pacScript'].data = prefix + script
|
config['pacScript'].data = prefix + script
|
||||||
|
@ -71,8 +71,12 @@ class Options
|
|||||||
@applyProfile('system')
|
@applyProfile('system')
|
||||||
else
|
else
|
||||||
@applyProfile(st['currentProfileName'] || @fallbackProfileName)
|
@applyProfile(st['currentProfileName'] || @fallbackProfileName)
|
||||||
).catch(ProfileNotExistError, =>
|
).catch((err) =>
|
||||||
|
if not err instanceof ProfileNotExistError
|
||||||
|
@log.error(err)
|
||||||
@applyProfile(@fallbackProfileName)
|
@applyProfile(@fallbackProfileName)
|
||||||
|
).catch((err) =>
|
||||||
|
@log.error(err)
|
||||||
).then => @getAll()
|
).then => @getAll()
|
||||||
|
|
||||||
@ready.then =>
|
@ready.then =>
|
||||||
@ -269,7 +273,7 @@ class Options
|
|||||||
ast = OmegaPac.PacGenerator.script(@_options, profile)
|
ast = OmegaPac.PacGenerator.script(@_options, profile)
|
||||||
if compress
|
if compress
|
||||||
ast = OmegaPac.PacGenerator.compress(ast)
|
ast = OmegaPac.PacGenerator.compress(ast)
|
||||||
Promise.resolve ast.print_to_string()
|
Promise.resolve OmegaPac.PacGenerator.ascii(ast.print_to_string())
|
||||||
|
|
||||||
_setAvailableProfiles: ->
|
_setAvailableProfiles: ->
|
||||||
profile = if @_currentProfileName then @currentProfile() else null
|
profile = if @_currentProfileName then @currentProfile() else null
|
||||||
|
@ -42,6 +42,7 @@ angular.module('omega').controller 'MasterCtrl', ($scope, $rootScope, $window,
|
|||||||
return if profile.profileType in ['DirectProfile', 'SystemProfile']
|
return if profile.profileType in ['DirectProfile', 'SystemProfile']
|
||||||
ast = OmegaPac.PacGenerator.script($rootScope.options, profileName)
|
ast = OmegaPac.PacGenerator.script($rootScope.options, profileName)
|
||||||
pac = ast.print_to_string(beautify: true, comments: true)
|
pac = ast.print_to_string(beautify: true, comments: true)
|
||||||
|
pac = OmegaPac.PacGenerator.ascii(pac)
|
||||||
blob = new Blob [pac], {type: "text/plain;charset=utf-8"}
|
blob = new Blob [pac], {type: "text/plain;charset=utf-8"}
|
||||||
fileName = profileName.replace(/\W+/g, '_')
|
fileName = profileName.replace(/\W+/g, '_')
|
||||||
saveAs(blob, "OmegaProfile_#{fileName}.pac")
|
saveAs(blob, "OmegaProfile_#{fileName}.pac")
|
||||||
|
Loading…
Reference in New Issue
Block a user