[tor-commits] [flashproxy/master] Understand IPv6 syntax in flashproxy.js.
dcf at torproject.org
dcf at torproject.org
Sun Sep 23 17:21:21 UTC 2012
commit 4cb229204fff9fb646860dcfc932ed440a7b6d88
Author: David Fifield <david at bamsoftware.com>
Date: Sun Sep 23 09:51:37 2012 -0700
Understand IPv6 syntax in flashproxy.js.
---
flashproxy.js | 19 ++++++++++++-------
1 files changed, 12 insertions(+), 7 deletions(-)
diff --git a/flashproxy.js b/flashproxy.js
index e9fbb37..a2e8863 100644
--- a/flashproxy.js
+++ b/flashproxy.js
@@ -291,14 +291,19 @@ function get_query_param_byte_count(query, param, default_val) {
/* Parse an address in the form "host:port". Returns an Object with
keys "host" (String) and "port" (int). Returns null on error. */
function parse_addr_spec(spec) {
- var groups;
- var host, port;
-
- groups = spec.match(/^([^:]+):(\d+)$/);
- if (!groups)
+ var m, host, port;
+
+ m = null;
+ /* IPv6 syntax. */
+ if (!m)
+ m = spec.match(/^\[([\0-9a-fA-F:.]+)\]:([0-9]+)$/);
+ /* IPv4 syntax. */
+ if (!m)
+ m = spec.match(/^([0-9.]+):([0-9]+)$/);
+ if (!m)
return null;
- host = groups[1];
- port = parseInt(groups[2], 10);
+ host = m[1];
+ port = parseInt(m[2], 10);
if (isNaN(port) || port < 0 || port > 65535)
return null;
More information about the tor-commits
mailing list