Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(935)

Side by Side Diff: net/proxy/proxy_resolver_script.h

Issue 40006: Fix error being thrown in isInNet() PAC js (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: use exec() and add a test for bad ip address Created 11 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « net/data/proxy_resolver_v8_unittest/pac_library_unittest.js ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* ***** BEGIN LICENSE BLOCK ***** 1 /* ***** BEGIN LICENSE BLOCK *****
2 * Version: MPL 1.1/GPL 2.0/LGPL 2.1 2 * Version: MPL 1.1/GPL 2.0/LGPL 2.1
3 * 3 *
4 * The contents of this file are subject to the Mozilla Public License Version 4 * The contents of this file are subject to the Mozilla Public License Version
5 * 1.1 (the "License"); you may not use this file except in compliance with 5 * 1.1 (the "License"); you may not use this file except in compliance with
6 * the License. You may obtain a copy of the License at 6 * the License. You may obtain a copy of the License at
7 * http://www.mozilla.org/MPL/ 7 * http://www.mozilla.org/MPL/
8 * 8 *
9 * Software distributed under the License is distributed on an "AS IS" basis, 9 * Software distributed under the License is distributed on an "AS IS" basis,
10 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License 10 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
42 42
43 // The following code was formatted from: 43 // The following code was formatted from:
44 // 'mozilla/netwerk/base/src/nsProxyAutoConfig.js' (1.55) 44 // 'mozilla/netwerk/base/src/nsProxyAutoConfig.js' (1.55)
45 // 45 //
46 // Using the command: 46 // Using the command:
47 // $ cat nsProxyAutoConfig.js | 47 // $ cat nsProxyAutoConfig.js |
48 // awk '/var pacUtils/,/EOF/' | 48 // awk '/var pacUtils/,/EOF/' |
49 // sed -e 's/^\s*$/""/g' | 49 // sed -e 's/^\s*$/""/g' |
50 // sed -e 's/"\s*[+]\s*$/"/g' | 50 // sed -e 's/"\s*[+]\s*$/"/g' |
51 // sed -e 's/"$/" \\/g' | 51 // sed -e 's/"$/" \\/g' |
52 // sed -e 's/\/(ipaddr);/\/.exec(ipaddr);/g' |
52 // grep -v '^var pacUtils =' 53 // grep -v '^var pacUtils ='
53 #define PROXY_RESOLVER_SCRIPT \ 54 #define PROXY_RESOLVER_SCRIPT \
54 "function dnsDomainIs(host, domain) {\n" \ 55 "function dnsDomainIs(host, domain) {\n" \
55 " return (host.length >= domain.length &&\n" \ 56 " return (host.length >= domain.length &&\n" \
56 " host.substring(host.length - domain.length) == domain);\n" \ 57 " host.substring(host.length - domain.length) == domain);\n" \
57 "}\n" \ 58 "}\n" \
58 "" \ 59 "" \
59 "function dnsDomainLevels(host) {\n" \ 60 "function dnsDomainLevels(host) {\n" \
60 " return host.split('.').length-1;\n" \ 61 " return host.split('.').length-1;\n" \
61 "}\n" \ 62 "}\n" \
62 "" \ 63 "" \
63 "function convert_addr(ipchars) {\n" \ 64 "function convert_addr(ipchars) {\n" \
64 " var bytes = ipchars.split('.');\n" \ 65 " var bytes = ipchars.split('.');\n" \
65 " var result = ((bytes[0] & 0xff) << 24) |\n" \ 66 " var result = ((bytes[0] & 0xff) << 24) |\n" \
66 " ((bytes[1] & 0xff) << 16) |\n" \ 67 " ((bytes[1] & 0xff) << 16) |\n" \
67 " ((bytes[2] & 0xff) << 8) |\n" \ 68 " ((bytes[2] & 0xff) << 8) |\n" \
68 " (bytes[3] & 0xff);\n" \ 69 " (bytes[3] & 0xff);\n" \
69 " return result;\n" \ 70 " return result;\n" \
70 "}\n" \ 71 "}\n" \
71 "" \ 72 "" \
72 "function isInNet(ipaddr, pattern, maskstr) {\n" \ 73 "function isInNet(ipaddr, pattern, maskstr) {\n" \
73 " var test = /^(\\d{1,3})\\.(\\d{1,3})\\.(\\d{1,3})\\.(\\d{1,3})$/(ipaddr); \n" \ 74 " var test = /^(\\d{1,3})\\.(\\d{1,3})\\.(\\d{1,3})\\.(\\d{1,3})$/.exec(ipa ddr);\n" \
74 " if (test == null) {\n" \ 75 " if (test == null) {\n" \
75 " ipaddr = dnsResolve(ipaddr);\n" \ 76 " ipaddr = dnsResolve(ipaddr);\n" \
76 " if (ipaddr == null)\n" \ 77 " if (ipaddr == null)\n" \
77 " return false;\n" \ 78 " return false;\n" \
78 " } else if (test[1] > 255 || test[2] > 255 || \n" \ 79 " } else if (test[1] > 255 || test[2] > 255 || \n" \
79 " test[3] > 255 || test[4] > 255) {\n" \ 80 " test[3] > 255 || test[4] > 255) {\n" \
80 " return false; // not an IP address\n" \ 81 " return false; // not an IP address\n" \
81 " }\n" \ 82 " }\n" \
82 " var host = convert_addr(ipaddr);\n" \ 83 " var host = convert_addr(ipaddr);\n" \
83 " var pat = convert_addr(pattern);\n" \ 84 " var pat = convert_addr(pattern);\n" \
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after
258 " date.setMonth(date.getUTCMonth());\n" \ 259 " date.setMonth(date.getUTCMonth());\n" \
259 " date.setDate(date.getUTCDate());\n" \ 260 " date.setDate(date.getUTCDate());\n" \
260 " date.setHours(date.getUTCHours());\n" \ 261 " date.setHours(date.getUTCHours());\n" \
261 " date.setMinutes(date.getUTCMinutes());\n" \ 262 " date.setMinutes(date.getUTCMinutes());\n" \
262 " date.setSeconds(date.getUTCSeconds());\n" \ 263 " date.setSeconds(date.getUTCSeconds());\n" \
263 " }\n" \ 264 " }\n" \
264 " return ((date1 <= date) && (date <= date2));\n" \ 265 " return ((date1 <= date) && (date <= date2));\n" \
265 "}\n" \ 266 "}\n" \
266 267
267 #endif // NET_PROXY_PROXY_RESOLVER_SCRIPT_H_ 268 #endif // NET_PROXY_PROXY_RESOLVER_SCRIPT_H_
OLDNEW
« no previous file with comments | « net/data/proxy_resolver_v8_unittest/pac_library_unittest.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698