Closed Bug 371409 Opened 17 years ago Closed 17 years ago

canonicalNum_ fails with 7 hex digits

Categories

(Toolkit :: Safe Browsing, defect)

defect
Not set
normal

Tracking

()

RESOLVED FIXED

People

(Reporter: bryner, Assigned: tony)

References

Details

(Keywords: fixed1.8.1.4)

Attachments

(2 files)

canonicalNum_ fails to parse a number like 0x1234567, because it takes the last 8 characters so the "x" is the first character.  parseInt() isn't able to parse that.  It should probably substitute \1 from the IS_HEX regexp, which trims off the leading 0x.
This rolls together fixes for this bug, bug 371412, and bug 371414.
Attachment #256435 - Flags: review?(bryner)
From bug 371412:
When parsing an address like "1.2.3.00x0", parseIPAddress ignores the failure
return from canonicalNum for the last octet, and returns a bogus IP address. 
It should fail immediately so that the hostname remains unchanged.

From bug 371414:
When parsing an IP address like "12.34.56.78 xy", we should ignore the space
and everything after it.  This is to match what Windows does when resolving the
host.

The exact test should be something like this:

if (host.length <= 15 && (host matches "^(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})
") {
  host = (match);
}

before testing against POSSIBLE_IP.
Comment on attachment 256435 [details] [diff] [review]
fixes to parseIPAddress

>Index: tests/test_bug371409.xhtml

It seems like it would be clearer to have all of the IP address parsing tests together, rather than creating a new test file for each bug.  But if this is generally the convention for unit tests, I guess it's ok.

Looks good.
Attachment #256435 - Flags: review?(bryner) → review+
On trunk.  I moved the tests into test_bug356355.xhtml file to be close to the other tests as you mentioned.  There's no real convention here.

Checking in content/enchash-decrypter.js;
/cvsroot/mozilla/toolkit/components/url-classifier/content/enchash-decrypter.js,v  <--  enchash-decrypter.js
new revision: 1.11; previous revision: 1.10
done
Checking in tests/test_bug356355.xhtml;
/cvsroot/mozilla/toolkit/components/url-classifier/tests/test_bug356355.xhtml,v  <--  test_bug356355.xhtml
new revision: 1.4; previous revision: 1.3
done
Status: NEW → RESOLVED
Closed: 17 years ago
Resolution: --- → FIXED
Attached patch branch patchSplinter Review
same as above except for branch (no mochitests)
Attachment #256508 - Flags: review?(bryner)
Attachment #256508 - Flags: approval1.8.1.3?
Flags: blocking1.8.1.3?
Comment on attachment 256508 [details] [diff] [review]
branch patch

This is missing the new files.
Which new files?
Comment on attachment 256508 [details] [diff] [review]
branch patch

Oops, sorry I was thinking of your other patch.
Attachment #256508 - Flags: review?(bryner) → review+
Flags: blocking1.8.1.4? → blocking1.8.1.4+
Comment on attachment 256508 [details] [diff] [review]
branch patch

approved for 1.8 branch, a=dveditz for drivers
Attachment #256508 - Flags: approval1.8.1.4? → approval1.8.1.4+
on branch

Checking in content/enchash-decrypter.js;
/cvsroot/mozilla/toolkit/components/url-classifier/content/enchash-decrypter.js,v  <--  enchash-decrypter.js
new revision: 1.1.2.6; previous revision: 1.1.2.5
done
Keywords: fixed1.8.1.4
Product: Firefox → Toolkit
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: