Closed Bug 366645 Opened 18 years ago Closed 18 years ago

Reference to undefined property FIND_TRAILING_DOTS_GLOBAL

Categories

(Toolkit :: Safe Browsing, defect)

x86
Windows XP
defect
Not set
normal

Tracking

()

RESOLVED FIXED

People

(Reporter: WeirdAl, Assigned: tony)

References

()

Details

(Keywords: fixed1.8.1.15)

Attachments

(2 files, 1 obsolete file)

Firefox 2 and trunk mention a FIND_TRAILING_DOTS_GLOBAL property.  But only once.  Venkman will correctly catch an error because of this.  The property is never defined.
Status: NEW → ASSIGNED
Attached patch fix typo for regex (obsolete) — Splinter Review
This typo was causing the .replace statement to do nothing.  Fortunately, it turns out we don't need this at all because the FIND_MULTIPLE_DOTS_GLOBAL that gets applied earlier does the same thing.  Simply removing the line and adding some tests to verify that getCanonicalHost still works.
Assignee: nobody → tony
Attachment #251158 - Flags: review?(mmchew)
Comment on attachment 251158 [details] [diff] [review]
fix typo for regex

>Index: toolkit/components/url-classifier/content/enchash-decrypter.js
>===================================================================
>RCS file: /cvsroot/mozilla/toolkit/components/url-classifier/content/enchash-decrypter.js,v
>retrieving revision 1.7
>diff -u -8 -p -r1.7 enchash-decrypter.js
>--- toolkit/components/url-classifier/content/enchash-decrypter.js	5 Dec 2006 23:36:01 -0000	1.7
>+++ toolkit/components/url-classifier/content/enchash-decrypter.js	11 Jan 2007 08:54:11 -0000
>@@ -79,17 +79,16 @@ PROT_EnchashDecrypter.REs.FIND_DODGY_CHA
> 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 = 
>   new RegExp("^\\.+|\\.+$", "g");

The patch looks fine, but could you please double check if we can get rid of some of the other REs?  It looks like FIND_DODGY_CHARS is not used, FIND_END_DOTS is not used, and I'm not convinced that FIND_END_DOTS_GLOBAL catches things that FIND_MULTIPLE_DOTS_GLOBAL doesn't.

> PROT_EnchashDecrypter.REs.FIND_MULTIPLE_DOTS = new RegExp("\\.{2,}");
> PROT_EnchashDecrypter.REs.FIND_MULTIPLE_DOTS_GLOBAL = 
>   new RegExp("\\.{2,}", "g");
>-PROT_EnchashDecrypter.REs.FIND_TRAILING_DOTS = new RegExp("\\.+$");
> 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]*$");
> PROT_EnchashDecrypter.REs.IS_DECIMAL = new RegExp("^[0-9]+$");
> PROT_EnchashDecrypter.REs.IS_HEX = new RegExp("^0[xX]([0-9a-fA-F]+)$");
> 
> // Regexps are given in perl regexp format. Unfortunately, JavaScript's
>@@ -238,19 +237,16 @@ PROT_EnchashDecrypter.prototype.getCanon
>     }
>   }
> 
>   escaped = escaped.toLowerCase();
>   return escaped;
> }
> 
> PROT_EnchashDecrypter.prototype.parseIPAddress_ = function(host) {
>-
>-  host = host.replace(this.REs_.FIND_TRAILING_DOTS_GLOBAL, "");
>-
>   if (!this.REs_.POSSIBLE_IP.test(host))
>     return "";
> 
>   var parts = host.split(".");
>   if (parts.length > 4)
>     return "";
> 
>   var allowOctal = !this.REs_.FIND_BAD_OCTAL.test(host);
>Index: testing/mochitest/tests/index.html
>===================================================================
>RCS file: /cvsroot/mozilla/testing/mochitest/tests/index.html,v
>retrieving revision 1.54
>diff -u -8 -p -r1.54 index.html
>--- testing/mochitest/tests/index.html	5 Jan 2007 23:23:50 -0000	1.54
>+++ testing/mochitest/tests/index.html	11 Jan 2007 08:54:12 -0000
>@@ -95,16 +95,17 @@ RunSet.runall = function() {
>       'test_bug358797.html',
>       'test_bug359657.html',
>       'test_bug359754.xul',
>       'test_bug362391.xhtml',
>       'test_bug362788.xhtml',
>       'test_bug364092.xhtml',
>       'test_bug364413.xhtml',
>       'test_bug365773.xul',
>+      'test_bug366645.xhtml',
>       'test_MochiKit-Async.html',
>       'test_MochiKit-Base.html',
>       'test_MochiKit-DateTime.html',
>       'test_MochiKit-DOM.html',
>       'test_MochiKit-Style.html',
>       'test_MochiKit-Format.html',
>       'test_MochiKit-Iter.html',
>       'test_MochiKit-Logging.html',
>Index: testing/mochitest/tests/test_bug366645.xhtml
>===================================================================
>RCS file: testing/mochitest/tests/test_bug366645.xhtml
>diff -N testing/mochitest/tests/test_bug366645.xhtml
>--- /dev/null	1 Jan 1970 00:00:00 -0000
>+++ testing/mochitest/tests/test_bug366645.xhtml	11 Jan 2007 08:54:12 -0000
>@@ -0,0 +1,53 @@
>+<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();
>+
>+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));
>+}
>+
>+]]>
>+</script>
>+</pre>
>+</body>
>+</html>
>+
Remove all unused regular expressions; remove invalid tests from old test file; add a bunch of new tests.
Attachment #251158 - Attachment is obsolete: true
Attachment #251595 - Flags: review?(mmchew)
Attachment #251158 - Flags: review?(mmchew)
Comment on attachment 251595 [details] [diff] [review]
remove unused regexes

Looks fine to me.
Attachment #251595 - Flags: review?(mmchew) → review+
on trunk
Status: ASSIGNED → RESOLVED
Closed: 18 years ago
Resolution: --- → FIXED
Comment on attachment 251595 [details] [diff] [review]
remove unused regexes

could this possibly be taken for the branch?
Attachment #251595 - Flags: approval1.8.1.15?
Comment on attachment 251595 [details] [diff] [review]
remove unused regexes

approved for 1.8.1.15, a=dveditz for release-drivers
Attachment #251595 - Flags: approval1.8.1.15? → approval1.8.1.15+
Checking in enchash-decrypter.js;
/cvsroot/mozilla/toolkit/components/url-classifier/content/enchash-decrypter.js,v  <--  enchash-decrypter.js
new revision: 1.1.2.9; previous revision: 1.1.2.8
done
Keywords: fixed1.8.1.15
What I committed to MOZILLA_1_8_BRANCH.
Product: Firefox → Toolkit
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: