Closed
Bug 140687
Opened 23 years ago
Closed 23 years ago
XPath substring('AB',2) returns empty string - should be 'B'.
Categories
(Core :: XSLT, defect)
Tracking
()
VERIFIED
FIXED
mozilla1.0
People
(Reporter: mozilla, Assigned: sicking)
References
()
Details
Attachments
(1 file)
|
748 bytes,
patch
|
axel
:
review+
jst
:
superreview+
jesup
:
approval+
|
Details | Diff | Splinter Review |
From Bugzilla Helper:
User-Agent: Mozilla/5.0 (Windows; U; Win 9x 4.90; en-US; rv:1.0rc1) Gecko/20020417
BuildID: 2002041711
<xsl:value-of select="substring('AB',2)"/>
returns an empty string, when it should return B.
Similarly,
<xsl:value-of select="substring('ABC',3)"/>
returns an empty string, but should return C.
I'm guessing this is a boundary condition bug - that it returns an empty string
if the index is >= the length, when it should be >. That's a C++ writers
mistake, after all, since XSLT starts indices at 1.
This bug can seriously mess up a recursion which processes a string a character
at a time, "losing" the last character.
The URL above is a simple stylesheet which tests a few basic cases.
Reproducible: Always
Steps to Reproduce:
1. Load the given URL above and check the output.
Actual Results:
substring('A',2) = '' ?
substring('AB',2) = '' ?
substring('ABC',2) = 'BC' ?
substring('ABCD',2) = 'BCD' ?
substring('ABC',3) = '' ?
Expected Results:
substring('A',2) = '' ?
substring('AB',2) = 'A' ?
substring('ABC',2) = 'BC' ?
substring('ABCD',2) = 'BCD' ?
substring('ABC',3) = 'C' ?
Updated•23 years ago
|
Status: UNCONFIRMED → NEW
Ever confirmed: true
Comment 1•23 years ago
|
||
hrm. mozilla 0.9.9 goes into an infinite loop on the testcase, that's prolly fixed
by the invalid XML crasher (bug 129006), as we don't process style PI's no more.
Peter, could you try RC1 (I didn't take that home yet, bad me), this might be
another pretty argument to get that landed
Comment 2•23 years ago
|
||
Sicking:
http://lxr.mozilla.org/seamonkey/source/extensions/transformiix/source/xpath/StringFunctionCall.cpp#172
, shouldn't that be floor(start + 0.5) > src.length() ? Reassigning to you
because a) doing maths is hard for me on a Sunday morning, b) it's your code and
c) you're not with Netscape ;-).
Assignee: peterv → sicking
| Assignee | ||
Comment 3•23 years ago
|
||
hmm.. yeah, something like that.
Anyway, Thomas, thanks for a good catch! Though you use the wrong namespace for
the html-output, either use none to get html output or use
http://www.w3.org/1999/xhtml to get xhtml output.
Status: NEW → ASSIGNED
| Assignee | ||
Comment 4•23 years ago
|
||
actually, this way saves a cycle or two. I.e. if the startposition is more then
length+0.5 (and thus rounded to more then length) we return an empty string
Comment 5•23 years ago
|
||
Attachment #81363 -
Flags: review+
Comment 6•23 years ago
|
||
Comment on attachment 81363 [details] [diff] [review]
patch to fix
sr=jst
Attachment #81363 -
Flags: superreview+
| Assignee | ||
Updated•23 years ago
|
Target Milestone: --- → mozilla1.0
Comment 7•23 years ago
|
||
Comment on attachment 81363 [details] [diff] [review]
patch to fix
a=rjesup@wgate.com. Make sure it's in the branch and trunk.
Attachment #81363 -
Flags: approval+
| Assignee | ||
Comment 8•23 years ago
|
||
landed on trunk, branch isn't open yet
| Assignee | ||
Comment 9•23 years ago
|
||
checked in on branch too
Thomas: it would be great if you could download a nightly build in a couple of
days and test that this now works as it should. If it does could you mark the
bug "verified"
Status: ASSIGNED → RESOLVED
Closed: 23 years ago
Resolution: --- → FIXED
Please add fixed1.0.0 keyword when you check in in the branch.
Keywords: fixed1.0.0
You need to log in
before you can comment on or make changes to this bug.
Description
•