Bug 366645 ��� Reference to undefined property FIND_TRAILING_DOTS_GLOBAL

patch: remove unused regexes
r=mmchew
This commit is contained in:
tony%ponderer.org 2007-01-18 05:55:09 +00:00
parent ee5e096fa7
commit 16f680cbdc
4 changed files with 114 additions and 37 deletions

View File

@ -102,6 +102,7 @@ RunSet.runall = function() {
'test_bug364092.xhtml',
'test_bug364413.xhtml',
'test_bug365773.xul',
'test_bug366645.xhtml',
'test_bug367164.html,
'test_MochiKit-Async.html',
'test_MochiKit-Base.html',

View File

@ -165,37 +165,13 @@ function testRE(re, inputValPairs) {
"RegExp broken: " + re + " (input: " + inputValPairs[i] + ")");
};
var tests =
["", false,
"normal chars;!@#$%^&*&(", false,
"MORE NORMAL ,./<>?;':{}", false,
"Slightly less\2 normal", true,
"\245 stuff \45", true,
"\31", true];
testRE(r.FIND_DODGY_CHARS, tests);
tests =
[no_dots, false,
one_dot, false,
leading_dot, true,
trailing_dots, true,
end_dots, true];
testRE(r.FIND_END_DOTS, tests);
tests =
[no_dots, false,
one_dot, false,
two_dots, true,
lots_o_dots, true,
multi_dots, true];
testRE(r.FIND_MULTIPLE_DOTS, tests);
tests =
[no_dots, false,
one_dot, false,
trailing_dot, true,
trailing_dots, true];
testRE(r.FIND_TRAILING_DOTS, tests);
testRE(r.FIND_MULTIPLE_DOTS_GLOBAL, tests);
tests =
["random junk", false,

View File

@ -0,0 +1,108 @@
<html xmlns="http://www.w3.org/1999/xhtml">
<!--
https://bugzilla.mozilla.org/show_bug.cgi?id=366645
-->
<head>
<title>Test for Bug 366645</title>
<script type="text/javascript" src="/MochiKit/packed.js"></script>
<script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
</head>
<body>
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=366645">Mozilla Bug 366645</a>
<p id="display"></p>
<div id="content" style="display: none">
</div>
<pre id="test">
<script class="testbody" type="text/javascript">
<![CDATA[
/** Test for Bug 366645 **/
netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect');
var Cc = Components.classes;
var Ci = Components.interfaces;
var table = Cc["@mozilla.org/url-classifier/table;1?type=url"].createInstance();
var componentScope = table.wrappedJSObject.__parent__;
ok(!!componentScope, "unable to get wrapped js object");
var PROT_EnchashDecrypter = componentScope.PROT_EnchashDecrypter;
var l = new PROT_EnchashDecrypter();
// Test getCanonicalUrl
var testing = {
"http://030.0254.0x89d5./": "http://24.172.137.213/",
"http://030.0254.0x89d5.../": "http://24.172.137.213/",
"http://...030.0254.0x89d5.../": "http://24.172.137.213/",
"http://127.0.0.1./": "http://127.0.0.1/",
"http://127.0.0.1/": "http://127.0.0.1/",
"http://a.b.c.d.e.f.g/path": "http://a.b.c.d.e.f.g/path",
"http://a.b.c.d.e.f.g...../path": "http://a.b.c.d.e.f.g/path",
"http://a.b.c.d.e.f.g./path": "http://a.b.c.d.e.f.g/path"
}
for (var key in testing) {
ok(l.getCanonicalUrl(key) === testing[key],
"getCanonicalUrl broken on " + key + "(got: " + l.getCanonicalUrl(key));
}
// Test individual regular expressions
function testRE(re, replaceStr, inputValPairs) {
for (var i = 0; i < inputValPairs.length; i += 2) {
var inStr = inputValPairs[i];
var outStr = inputValPairs[i + 1];
ok(inStr.replace(re, replaceStr) == outStr,
uneval(inStr) + ".replace(" + uneval(re) + "," + uneval(replaceStr) + ") == " + uneval(outStr) + ")");
}
};
/*
- [no_dots, false,
- one_dot, false,
- trailing_dot, true,
- trailing_dots, true];
-testRE(r.FIND_TRAILING_DOTS, tests);
*/
testing = [
"", "",
"normal chars;!@#$%^&*&(", "normal chars;!@#$%^&*&(",
"MORE NORMAL ,./<>?;':{}", "MORE NORMAL ,./<>?;':{}",
"Slightly less\2 normal", "Slightly less normal",
"\245 stuff \4\5foo", " stuff foo",
];
testRE(PROT_EnchashDecrypter.REs.FIND_DODGY_CHARS_GLOBAL, "", testing);
testing = [
"", "",
"abcd123;[]", "abcd123;[]",
"abc.123", "abc.123",
"two..dots", "two..dots",
"trailing.", "trailing",
"trailing..", "trailing",
".leading", "leading",
"..leading", "leading",
".both.", "both",
".both..", "both",
"..both.", "both",
"..both..", "both",
"..a.b.c.d..", "a.b.c.d",
"..127.0.0.1..", "127.0.0.1",
];
testRE(PROT_EnchashDecrypter.REs.FIND_END_DOTS_GLOBAL, "", testing);
testing = [
"", "",
"nodots", "nodots",
"127.0.0.1", "127.0.0.1",
".127.0.0.1.", ".127.0.0.1.",
"127..0.0.1", "127.0.0.1",
"127.0..0.1", "127.0.0.1",
"127..0..0..1", "127.0.0.1",
];
testRE(PROT_EnchashDecrypter.REs.FIND_MULTIPLE_DOTS_GLOBAL, ".", testing);
]]>
</script>
</pre>
</body>
</html>

View File

@ -74,18 +74,13 @@ PROT_EnchashDecrypter.SALT_LENGTH = PROT_EnchashDecrypter.DATABASE_SALT.length;
PROT_EnchashDecrypter.MAX_DOTS = 5;
PROT_EnchashDecrypter.REs = {};
PROT_EnchashDecrypter.REs.FIND_DODGY_CHARS =
new RegExp("[\x01-\x1f\x7f-\xff]+");
PROT_EnchashDecrypter.REs.FIND_DODGY_CHARS_GLOBAL =
PROT_EnchashDecrypter.REs.FIND_DODGY_CHARS_GLOBAL =
new RegExp("[\x01-\x1f\x7f-\xff]+", "g");
PROT_EnchashDecrypter.REs.FIND_END_DOTS = new RegExp("^\\.+|\\.+$");
PROT_EnchashDecrypter.REs.FIND_END_DOTS_GLOBAL =
PROT_EnchashDecrypter.REs.FIND_END_DOTS_GLOBAL =
new RegExp("^\\.+|\\.+$", "g");
PROT_EnchashDecrypter.REs.FIND_MULTIPLE_DOTS = new RegExp("\\.{2,}");
PROT_EnchashDecrypter.REs.FIND_MULTIPLE_DOTS_GLOBAL =
PROT_EnchashDecrypter.REs.FIND_MULTIPLE_DOTS_GLOBAL =
new RegExp("\\.{2,}", "g");
PROT_EnchashDecrypter.REs.FIND_TRAILING_DOTS = new RegExp("\\.+$");
PROT_EnchashDecrypter.REs.POSSIBLE_IP =
PROT_EnchashDecrypter.REs.POSSIBLE_IP =
new RegExp("^((?:0x[0-9a-f]+|[0-9\\.])+)$", "i");
PROT_EnchashDecrypter.REs.FIND_BAD_OCTAL = new RegExp("(^|\\.)0\\d*[89]");
PROT_EnchashDecrypter.REs.IS_OCTAL = new RegExp("^0[0-7]*$");
@ -243,9 +238,6 @@ PROT_EnchashDecrypter.prototype.getCanonicalHost = function(str, opt_maxDots) {
}
PROT_EnchashDecrypter.prototype.parseIPAddress_ = function(host) {
host = host.replace(this.REs_.FIND_TRAILING_DOTS_GLOBAL, "");
if (!this.REs_.POSSIBLE_IP.test(host))
return "";