mirror of
https://github.com/zero-peak/ZeroOmega.git
synced 2025-01-22 15:08:12 -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) ->
|
||||
hex = char.charCodeAt(0).toString(16)
|
||||
result = '\\u'
|
||||
result += '0' for _ in [hex.length..4]
|
||||
result += '0' for _ in [hex.length...4]
|
||||
result += hex
|
||||
return result
|
||||
|
||||
compress: (ast) ->
|
||||
|
@ -6,7 +6,9 @@ chromeApiPromisifer = (originalMethod) ->
|
||||
new Promise (resolve, reject) =>
|
||||
callback = (callbackArgs...) ->
|
||||
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
|
||||
resolve(callbackArgs[0])
|
||||
else
|
||||
|
@ -135,7 +135,8 @@ class ChromeOptions extends OmegaTarget.Options
|
||||
data: null
|
||||
mandatory: true
|
||||
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')
|
||||
prefix = "/*OmegaProfile*#{profileName}*#{profile.revision}*/"
|
||||
config['pacScript'].data = prefix + script
|
||||
|
@ -71,8 +71,12 @@ class Options
|
||||
@applyProfile('system')
|
||||
else
|
||||
@applyProfile(st['currentProfileName'] || @fallbackProfileName)
|
||||
).catch(ProfileNotExistError, =>
|
||||
).catch((err) =>
|
||||
if not err instanceof ProfileNotExistError
|
||||
@log.error(err)
|
||||
@applyProfile(@fallbackProfileName)
|
||||
).catch((err) =>
|
||||
@log.error(err)
|
||||
).then => @getAll()
|
||||
|
||||
@ready.then =>
|
||||
@ -269,7 +273,7 @@ class Options
|
||||
ast = OmegaPac.PacGenerator.script(@_options, profile)
|
||||
if compress
|
||||
ast = OmegaPac.PacGenerator.compress(ast)
|
||||
Promise.resolve ast.print_to_string()
|
||||
Promise.resolve OmegaPac.PacGenerator.ascii(ast.print_to_string())
|
||||
|
||||
_setAvailableProfiles: ->
|
||||
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']
|
||||
ast = OmegaPac.PacGenerator.script($rootScope.options, profileName)
|
||||
pac = ast.print_to_string(beautify: true, comments: true)
|
||||
pac = OmegaPac.PacGenerator.ascii(pac)
|
||||
blob = new Blob [pac], {type: "text/plain;charset=utf-8"}
|
||||
fileName = profileName.replace(/\W+/g, '_')
|
||||
saveAs(blob, "OmegaProfile_#{fileName}.pac")
|
||||
|
Loading…
Reference in New Issue
Block a user