Closed Bug 429347 Opened 16 years ago Closed 16 years ago

URL parser gets confused by ref with no path

Categories

(Core :: Networking, defect)

x86
Linux
defect
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla1.9.1b1

People

(Reporter: bzbarsky, Assigned: michal)

Details

Attachments

(1 file, 3 obsolete files)

Parsing "http://example.com#bar" produces an nsStandardURL with an mBasename segment with pos == 0, len == -1.  Parsing "http://example.com/#bar" gives an mBasename segment with pos == 18, len == 0.

The resulting URI objects serialize to the same thing, but don't test equal via equals().  This is wrong.  See bug 429128 comment 12 and bug 429128 comment 14.
Attached patch fix + unit test (obsolete) — Splinter Review
Assignee: nobody → michal
Status: NEW → ASSIGNED
Attachment #324810 - Flags: review?(cbiesinger)
Wouldn't it be better to fix ParsePath?  I guess that pretty purposefully does the -1 thing....

If we do want to do this, wouldn't it make more sense to adjust the filename len first, _then_ do the > 0 compare and ensuing block?
Attached patch patch v2 (obsolete) — Splinter Review
fixed nsBaseURLParser::ParsePath()
Attachment #324810 - Attachment is obsolete: true
Attachment #340919 - Flags: review?(bzbarsky)
Attachment #324810 - Flags: review?(cbiesinger)
So with that patch, how do we parse "http://example.com" as compared to "http://example.com/"?  Do both end up with mBasename of len == -1?  Or len == 0?  Or something else?
This isn't affected by this patch and both are mBasename = {mPos = 19, mLen = 0}.
Attachment #340919 - Flags: superreview?(cbiesinger)
Attachment #340919 - Flags: review?(bzbarsky)
Attachment #340919 - Flags: review+
Comment on attachment 340919 [details] [diff] [review]
patch v2

>Index: netwerk/base/src/nsURLParsers.cpp
>+    // an empty file path is no file path only if there is neither param/query/ref

s/neither/no/

>Index: netwerk/test/unit/test_bug429347.js

Add as a test the thing I asked about with no query/param/ref?

I still don't see how that works; do we never even hit this function in that case?  Depending on that seems pretty fragile...

r=bzbarsky with that satisfactorily explained.
Oh, I'd like biesi to ok this too.
Attached patch patch v3 (obsolete) — Splinter Review
I think I've found a better place to fix this bug. Please have a look at the new patch.
Attachment #340919 - Attachment is obsolete: true
Attachment #341035 - Flags: review?(bzbarsky)
Attachment #340919 - Flags: superreview?(cbiesinger)
Comment on attachment 341035 [details] [diff] [review]
patch v3

This also looks good to me (and still needs a glance from biesi)
Attachment #341035 - Flags: review?(cbiesinger)
Attachment #341035 - Flags: review?(bzbarsky)
Attachment #341035 - Flags: review+
Attachment #341035 - Flags: review?(cbiesinger) → review+
Comment on attachment 341035 [details] [diff] [review]
patch v3

You can reenable the line in netwerk/test/unit/test_standardurl.js now, right?
Attached patch patch v4Splinter Review
(In reply to comment #10)
> (From update of attachment 341035 [details] [diff] [review])
> You can reenable the line in netwerk/test/unit/test_standardurl.js now, right?

You're right.
Attachment #341035 - Attachment is obsolete: true
Attachment #341123 - Flags: superreview?(cbiesinger)
Attachment #341123 - Flags: superreview?(cbiesinger) → superreview+
Keywords: checkin-needed
http://hg.mozilla.org/mozilla-central/rev/3fcf14282433
Status: ASSIGNED → RESOLVED
Closed: 16 years ago
Keywords: checkin-needed
Resolution: --- → FIXED
Target Milestone: --- → mozilla1.9.1b1
Flags: in-testsuite+
Note that a fix for 665706 will affect a test case over here:

  // see https://bugzilla.mozilla.org/show_bug.cgi?id=665706
  // ";" is not parsed as special anymore and thus ends up
  // in the authority component (see RFC 3986)
  uri1.spec = "http://example.com;bar";
  uri2.spec = "http://example.com/;bar";
  do_check_false(uri1.equals(uri2));

...so these two intentionally do not compare equal anymore.
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: