Open
Bug 322167
Opened 19 years ago
Updated 2 years ago
Title chopping from bug 319004 might split a character in the middle
Categories
(Core :: XPCOM, defect)
Core
XPCOM
Tracking
()
REOPENED
People
(Reporter: ajschult784, Unassigned)
Details
Attachments
(2 files)
(deleted),
patch
|
smontagu
:
review+
darin.moz
:
superreview+
|
Details | Diff | Splinter Review |
(deleted),
patch
|
darin.moz
:
review+
darin.moz
:
superreview+
|
Details | Diff | Splinter Review |
------- Comment #61 From Christian Biesinger (:bi) (reviews slower than usual) 2005-12-17 12:58 PST [reply] -------
+ nsAutoString titleString(StringHead(aTitle, HISTORY_TITLE_LENGTH_MAX));
this might split a character in the middle :-/ (a non-BMP one)
Comment 1•19 years ago
|
||
Even a string made purely of BMP chacters can be problematic because Unicode-character boundaries are not grapheme boundaries. In the absence of grapheme boundary checking API, perhaps we may chop it at the last 'space-like' (not necessarily space-like but any 'non-base' character) within the max length limit.
Aha,,, if this is only about history corruption, then we just have to modify |StringHead(str, maxlen)| to rewind one PRUnichar and return one 'unit' fewer than maxlen if the last character happens to be a 'high surrogate character'.
Reporter | ||
Comment 2•19 years ago
|
||
Right, no need to be fancy, just have a valid string.
I have a patch that should work, but I can't seem to create a page with a title that would trigger the problem. I made a page with the synthetic title:
<title>������</title>
but IS_HIGH_SURROGATE(titleString.Last()) returns false. How can I make a title with BMP characters?
Comment 3•19 years ago
|
||
Surrogates in numeric entitities are treated as invalid. Try <title>𐑑𐑲𐑑𐑩𐑤</title>
Reporter | ||
Comment 4•19 years ago
|
||
thanks smontagu, that worked.
Attachment #207476 -
Flags: superreview?(darin)
Attachment #207476 -
Flags: review?(smontagu)
Updated•19 years ago
|
Attachment #207476 -
Flags: superreview?(darin) → superreview+
Updated•19 years ago
|
Attachment #207476 -
Flags: review?(smontagu) → review+
Reporter | ||
Comment 5•19 years ago
|
||
FIXED
Status: NEW → RESOLVED
Closed: 19 years ago
Resolution: --- → FIXED
Reporter | ||
Comment 6•19 years ago
|
||
ugh, this is unhappy now with an empty title (like for about:blank). nsTSubstring::Last reads memory from before the start of the empty buffer. A debug build asserts.
Status: RESOLVED → REOPENED
Resolution: FIXED → ---
Reporter | ||
Comment 7•19 years ago
|
||
This makes it kick in only if it actually cut the string.
Attachment #207587 -
Flags: superreview?(darin)
Attachment #207587 -
Flags: review?(darin)
Comment 8•19 years ago
|
||
hmm, that makes me wonder if ...DependentSubstring shouldn't be doing this internally rather than callers having to worry about it. We never want to return a substring that isn't legal UTF-16, right?
Comment 9•19 years ago
|
||
Maybe you should use a more explicit conditional e.g.
if (length < MAX)
newstring = oldstring;
else if (oldstring[MAX - 1] is surrogate)
newstring = head(oldstring, MAX - 1);
else
newstring = head(oldstring, MAX);
Comment 10•19 years ago
|
||
Please check this in, even if you don't have reviews yet. The tree is orange, and really should be closed because of it.
Reporter | ||
Comment 11•19 years ago
|
||
Comment on attachment 207587 [details] [diff] [review]
patch
this is in the trunk
Comment 12•19 years ago
|
||
(In reply to comment #8)
> hmm, that makes me wonder if ...DependentSubstring shouldn't be doing this
> internally rather than callers having to worry about it. We never want to
> return a substring that isn't legal UTF-16, right?
I agree. That's what I meant in the 2nd paragraph of comment #1 with 'last character' replaced by 'last 16-bit unit'
Updated•19 years ago
|
Attachment #207587 -
Flags: superreview?(darin)
Attachment #207587 -
Flags: superreview+
Attachment #207587 -
Flags: review?(darin)
Attachment #207587 -
Flags: review+
Comment 13•7 years ago
|
||
Moving to XPCOM to figure out if there's anything more to do in DependentSubString, it's possible it has been fixed in the meanwhile. Otherwise this was RESO/FIXED years ago (patches landed but it was never closed)
Component: History: Global → XPCOM
Comment 14•2 years ago
|
||
The bug assignee didn't login in Bugzilla in the last 7 months, so the assignee is being reset.
Assignee: ajschult784 → nobody
Updated•2 years ago
|
Severity: normal → S3
You need to log in
before you can comment on or make changes to this bug.
Description
•