Closed Bug 163225 Opened 22 years ago Closed 22 years ago

success or failure of ExtractScheme is not enough to decide if a url is absolute or relative

Categories

(Core :: Networking, defect, P3)

defect

Tracking

()

VERIFIED FIXED
mozilla1.2alpha

People

(Reporter: andreas.otte, Assigned: andreas.otte)

References

Details

Attachments

(1 file, 4 obsolete files)

Success or failure of ExtractScheme is not enough to decide if an url is
absolute or relative after checkin of patch of bug 32966
Current NewURI functions use ExtractScheme to decide if an url is absolute or
relative. It is not so easy anymore ... leave that decision to ::Resolve.
Blocks: 40670
OS: Linux → All
Hardware: PC → All
Priority: -- → P3
Target Milestone: --- → mozilla1.2alpha
+    if (!NS_SUCCEEDED(rv)) {

use if (NS_FAILED(rv))
Attached patch better patch (obsolete) — Splinter Review
incorporating cbiesingers suggestion
Attachment #95703 - Attachment is obsolete: true
Attached patch better performing patch (obsolete) — Splinter Review
this version checks in nsStandardURL::Init before calling resolve to reduce the
costs of removing the check in nsIOService.cpp. Thanks Darin!
Attachment #95706 - Attachment is obsolete: true
Bradley, this is a followup to bug 32966, want to r=?
Comment on attachment 96687 [details] [diff] [review]
better performing patch


> >+    if (baseURI) {
>+        PRUint32 start, end;
>+        // pull out the scheme and where it ends
>+        nsresult rv = ExtractURLScheme(spec, &start, &end, nsnull);
>+        if (NS_SUCCEEDED(rv)) {
>+            nsACString::const_iterator slash;
>+            spec.BeginReading(slash);
>+            slash.advance(end);
>+            // then check if // follows
>+            // if it follows aSpec is really absolute ... 
>+            // ignore aBaseURI in this case
>+            if (*slash == '/' && *(++slash) == '/')

Do you need to check for urls like |http:/|, where this will run of the end of
the string?

r=bbaetz if those invalid urls have been rejected by then.
Attachment #96687 - Flags: review+
Comment on attachment 96687 [details] [diff] [review]
better performing patch

andreas: i think bbaetz is right... we will have to add an additional length
check in there.  either compare slash to EndReading, or check (spec.Length() >
end+1)??
Attachment #96687 - Flags: superreview+
Attached patch patch with length check (obsolete) — Splinter Review
please move forward r= ans sr=
Attachment #96687 - Attachment is obsolete: true
There are two calls to resource urls during startup which are not stopped by
this new check in ::Init and get only resolved as absolute urls by ::Resolve. I
think that is acceptable.
Comment on attachment 96911 [details] [diff] [review]
patch with length check

>Index: mozilla/netwerk/base/src/nsStandardURL.cpp

>+    if (baseURI) {
>+        PRUint32 start, end;
>+        // pull out the scheme and where it ends
>+        nsresult rv = ExtractURLScheme(spec, &start, &end, nsnull);
>+        if (NS_SUCCEEDED(rv)) {

i think the spec.Length() check should appear here instead:

	  if (NS_SUCCEEDED(rv) && (spec.Length() > end+1)) {
Attachment #96911 - Flags: needs-work+
yes, this is better, this will save even more time
Attachment #96911 - Attachment is obsolete: true
Comment on attachment 96916 [details] [diff] [review]
patch with moved length check

sr=darin

nit:
"if it follows, aSpec is really absolute"

need a comma after follows :)
Attachment #96916 - Flags: superreview+
Done in my file, but I wont attach another patch for that ... Bradley could you
move your r= to the current patch?
Comment on attachment 96916 [details] [diff] [review]
patch with moved length check

r=bbaetz
Attachment #96916 - Flags: review+
fix is in
Status: NEW → RESOLVED
Closed: 22 years ago
Resolution: --- → FIXED
*** Bug 165579 has been marked as a duplicate of this bug. ***
Keywords: mozilla1.0.1
Comment on attachment 96916 [details] [diff] [review]
patch with moved length check

a=rjesup@wgate.com for 1.0 branch checkin

Change mozilla1.0.2+ to fixed1.0.2 when checked in.
Attachment #96916 - Flags: approval+
This caused regressions bug 166085 and bug 166175
Depends on: 166085, 166175
Please verify the bug. Once verified, change the keyword fixed1.0.2 to
verified1.0.2 
Hi, can someone give me a test or some steps?
Checked using lxr and the patch is checked in on both the trunk and branch. 

verified.  

Status: RESOLVED → VERIFIED
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: