Closed
Bug 117410
Opened 24 years ago
Closed 24 years ago
image not loaded if SRC URL has a leading SPACE character.
Categories
(Core :: Networking: HTTP, defect)
Tracking
()
RESOLVED
FIXED
People
(Reporter: jrgmorrison, Assigned: badami)
References
Details
(Whiteboard: [patch needs r/sr=])
Attachments
(1 file, 8 obsolete files)
|
1.29 KB,
patch
|
darin.moz
:
superreview+
asa
:
approval+
|
Details | Diff | Splinter Review |
Almost hate to file a bug like this, but this works in Nav4.x, IE and
worked in the 6.2 release. It stopped working between 11/15 and 11/20
(of builds that I had lying around). Given that the url rewrite landed
on 11/15, I'm guessing that this is related (although possibly not).
Anyways ... if you have a <IMG SRC="..."> and the URL in the SRC
attribute has a leading SPACE character, the image will not
load. Curiously, if it has a leading TAB character, the image will
load (i.e., a leading TAB is stripped, but a leading SPACE is not
stripped from the URL).
I'll attach a simple test case in one moment.
| Reporter | ||
Comment 1•24 years ago
|
||
| Reporter | ||
Comment 2•24 years ago
|
||
take two. (I accidentally expanded the tab in the first attachment when
cutting/pasting from a remote term window).
Attachment #63055 -
Attachment is obsolete: true
Comment 3•24 years ago
|
||
Hmmmm ... if I remember correctly stripping spaces was removed from resolving
relative urls some time ago, not just with the urlparser rewrite. AFAIK that was
moved to the customers of ::Resolve because some of them wanted the space
preserved, some not.
Comment 5•24 years ago
|
||
src="" is a URI which is defined as a CDATA element.
http://www.w3.org/TR/html401/sgml/dtd.html#URI
This is a likely dupe of Bug 87894 - "Leading and trailing whitespace should be
trimmed from CDATA attributes in quirks mode"
The fact that it worked on the branch was because of bug 79929 I'm sure...
Comment 7•24 years ago
|
||
This is not a networking issue in my opinion. We should not strip
leading/trailing spaces on relative urls. This has to be done by the customer of
::Resolve in context of the situation and before the string is given to ::Resolve.
| Assignee | ||
Comment 8•24 years ago
|
||
| Assignee | ||
Updated•24 years ago
|
Whiteboard: [patch needs r/sr=]
Comment 9•24 years ago
|
||
Okay, I was on the wrong trip here, thinking about relative urls. If it is an
absolute URL the spaces should be left/right trimmed from the url. But why not
move that trim into FilterString?
| Assignee | ||
Comment 10•24 years ago
|
||
Looks like StripChars does what the FilterString routine was doing.
Note that i need to pass the cleaned up spec to ParseURL and
BuildNormalizedSpec since they will be noting offsets into this string for the
various URI components.
Comment 11•24 years ago
|
||
Comment on attachment 71644 [details] [diff] [review]
remove FilterString and replace it by StripChars
vinay: FilterString does more than StripChars... it avoids a costly string copy
when there is nothing to filter. let's not remove it. instead, can you fix
FilterString to do the right thing?
Attachment #71644 -
Flags: needs-work+
| Assignee | ||
Updated•24 years ago
|
Attachment #71637 -
Attachment is obsolete: true
| Assignee | ||
Updated•24 years ago
|
Attachment #71644 -
Attachment is obsolete: true
| Assignee | ||
Comment 12•24 years ago
|
||
1. Return with PR_FALSE on null string.
2. Strip leading spaces.
3. Strip trailing spaces.
Comment 13•24 years ago
|
||
Comment on attachment 71853 [details] [diff] [review]
modify FilterString
Append null terminates, so there is no need to worry about null terminating
|p|... also no need to worry about restoring str to original state to preserve
constness.
Attachment #71853 -
Flags: needs-work+
| Assignee | ||
Comment 14•24 years ago
|
||
Attachment #63057 -
Attachment is obsolete: true
Attachment #71853 -
Attachment is obsolete: true
Comment 15•24 years ago
|
||
Comment on attachment 72011 [details] [diff] [review]
with darins comments
a few more comments (i should have caught these before)...
> nsStandardURL::FilterString(const char *str, nsCString &result)
> {
>+ if (!str)
>+ return PR_FALSE;
this check should be moved to nsStandardURL::SetSpec after the call to Clear()
>+ PRBool firstNonWhiteSpace = PR_FALSE;
instead of checking this variable everytime through the loop we
should have a separate loop for removing leading whitespace.
like so:
for (; *p; ++p) {
if (*p == ' ') {
writing = PR_TRUE;
str = p + 1;
}
}
then follow with the existing loop to remove control characters:
for (; *p; ++p) {
if (*p == '\t' || ... ) {
// ...
}
}
and finally, a third loop to strip trailing white space:
>+ // Remove trailing spaces if any
>+ const char* end = (char*)p;
>+ while (((p-1) >= str) && (*(p-1) == ' ')) {
>+ writing = PR_TRUE;
>+ p--;
> }
doesn't look like |end| is needed.
i'm being especially picky here because SetSpec is called thousands of
times during startup and thousands of times during page load.
Attachment #72011 -
Flags: needs-work+
| Assignee | ||
Comment 16•24 years ago
|
||
| Assignee | ||
Updated•24 years ago
|
Attachment #72011 -
Attachment is obsolete: true
Comment 17•24 years ago
|
||
Comment on attachment 72349 [details] [diff] [review]
with 3 loops
>Index: nsStandardURL.cpp
>+ // Remove leading spaces
>+ while (*p && (*p == ' ')) {
while (*p == ' ')
is equivalent
>+ NS_PRECONDITION(spec, "null pointer");
>+ if(!spec)
>+ return NS_ERROR_INVALID_ARG;
sorry, i think i gave you misleading advice. either it is valid
to pass in a NULL spec, meaning that the URL gets completely
cleared, or it is invalid to pass in a NULL spec, and nothing
should change. this patch would not satisfy either approach.
i'd prefer to say that a NULL spec simply clears the URL.
so this NULL check (after the call to Clear()), should silently
return NS_OK.
Attachment #72349 -
Flags: needs-work+
| Assignee | ||
Comment 18•24 years ago
|
||
1. Changed while (*p && (*p == ' ')) to while (*p == ' ')
2. Return NS_OK if spec was null after clearing URL.
Attachment #72349 -
Attachment is obsolete: true
Comment 19•24 years ago
|
||
Comment on attachment 72553 [details] [diff] [review]
oen more
i meant that the NS_PRECONDITION should be removed since it seems to suggest
that the caller is in error... with that, sr=darin :-)
Attachment #72553 -
Flags: superreview+
Comment 20•24 years ago
|
||
Comment on attachment 72553 [details] [diff] [review]
oen more
r=bbaetz with the precondition removed.
Attachment #72553 -
Flags: review+
Shouldn't you filter out the control characters before stripping
leading/trailing whitespace? Otherwise stuff like " \n http://ocallahan.org"
won't work.
| Assignee | ||
Comment 22•24 years ago
|
||
Darin, Bbaetz
Can u folks r/srf this once more please ?
Attachment #72553 -
Attachment is obsolete: true
Comment 23•24 years ago
|
||
Comment on attachment 72952 [details] [diff] [review]
removing leading tabs and CRLF too
badami: you're going to hate this, but the old for loop in the code could be
collapsed into a while() loop which would avoid testing (*p != 0) :-)
with that sr=darin
Attachment #72952 -
Flags: superreview+
Comment 24•24 years ago
|
||
Comment on attachment 72952 [details] [diff] [review]
removing leading tabs and CRLF too
a=asa (on behalf of drivers) for checkin to the 1.0 trunk
Attachment #72952 -
Flags: approval+
| Assignee | ||
Comment 25•24 years ago
|
||
fixed with checkin
D:\mozilla\netwerk\base\src>cvs commit
cvs commit: Examining .
Checking in nsStandardURL.cpp;
/cvsroot/mozilla/netwerk/base/src/nsStandardURL.cpp,v <-- nsStandardURL.cpp
new revision: 1.17; previous revision: 1.16
done
Status: NEW → RESOLVED
Closed: 24 years ago
Resolution: --- → FIXED
Comment 26•24 years ago
|
||
*** Bug 135168 has been marked as a duplicate of this bug. ***
You need to log in
before you can comment on or make changes to this bug.
Description
•