pac_utils.js: remove excessive escaping
Looks like the implementation was derived from Mozilla's nsProxyAutoConfig.js, which is evaluated twice. It requires double escaping. In our case excessive escaping is harmful. In particular it makes ip-matching regexp in isInNet() invalid and makes it really slow as we go to dnsResolve() all the time, even when it's not needed. Signed-off-by: Kirill A. Shutemov <kirill@shutemov.name>
This commit is contained in:
parent
13213724b0
commit
ac3c8bb319
@ -61,7 +61,7 @@ function convert_addr(ipchars) {
|
||||
}
|
||||
|
||||
function isInNet(ipaddr, pattern, maskstr) {
|
||||
var test = /^(\\d{1,3})\\.(\\d{1,3})\\.(\\d{1,3})\\.(\\d{1,3})$/
|
||||
var test = /^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/
|
||||
.exec(ipaddr);
|
||||
if (test == null) {
|
||||
ipaddr = dnsResolve(ipaddr);
|
||||
@ -92,9 +92,9 @@ function localHostOrDomainIs(host, hostdom) {
|
||||
}
|
||||
|
||||
function shExpMatch(url, pattern) {
|
||||
pattern = pattern.replace(/\\./g, '\\\\.');
|
||||
pattern = pattern.replace(/\\*/g, '.*');
|
||||
pattern = pattern.replace(/\\?/g, '.');
|
||||
pattern = pattern.replace(/\./g, '\\.');
|
||||
pattern = pattern.replace(/\*/g, '.*');
|
||||
pattern = pattern.replace(/\?/g, '.');
|
||||
var newRe = new RegExp('^'+pattern+'$');
|
||||
return newRe.test(url);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user