Closed
Bug 237585
Opened 21 years ago
Closed 19 years ago
backspace/delete in editor don't handle Unicode plane 1 characters correctly (UTF-16 surrogate pairs)
Categories
(Core :: DOM: Editor, defect, P2)
Tracking
()
RESOLVED
FIXED
Future
People
(Reporter: dbaron, Assigned: dbaron)
References
Details
(Whiteboard: [patch])
Attachments
(2 files, 2 obsolete files)
(deleted),
text/html; charset=UTF-8
|
Details | |
(deleted),
patch
|
Details | Diff | Splinter Review |
[This comment is in UTF-8.]
Backspace and delete in the editor (or in text inputs at least, but I assume
it's a general problem) don't handle Unicode characters outside of plane 0 (the
BMP, U+0000 to U+FFFF) correctly. What appears to be happening is that they
treat the two surrogates as separate characters, and a single backspace or
delete only deletes one of the surrogates rather than the whole character.
(Note to the uninformed: UTF-16 encodes characters in the range U+10000 to
U+10FFFF using two 16-bit values, a high surrogate (in the range U+D800 to
U+DBFF) followed by a low surrogate (in the range U+DC00 to U+DFFF).)
It's worth noting that selection seems to handle non-BMP characters fine.
The attached testcase contains a text input with the string "a
Assignee | ||
Comment 1•21 years ago
|
||
Assignee | ||
Comment 2•21 years ago
|
||
I think the place to fix this is probably somewhere around the 4 calls to
CreateTxnForDeleteText in nsEditor::CreateTxnForDeleteInsertionPoint .
Assignee | ||
Comment 3•21 years ago
|
||
(Although I wonder why there need to be two separate implementations -- why
can't backspace and delete when the selection is collapsed be implemented by
extending the selection and then deleting it?)
Assignee | ||
Comment 4•21 years ago
|
||
This works, but I need to go over the error-handling and make sure it's
correct, and also test in a debug build.
Comment 5•21 years ago
|
||
*** Bug 173541 has been marked as a duplicate of this bug. ***
Assignee | ||
Updated•21 years ago
|
Assignee: mozeditor → dbaron
Priority: -- → P2
Whiteboard: [patch]
Target Milestone: --- → mozilla1.8alpha
Assignee | ||
Comment 6•20 years ago
|
||
Comment on attachment 144151 [details] [diff] [review]
patch
So, I don't remember what error handling issue I wanted to look at, and it
seems fine in a debug build, so requesting review.
Attachment #144151 -
Flags: review?(daniel)
Assignee | ||
Updated•20 years ago
|
Attachment #144151 -
Flags: superreview?(sfraser_bugs)
Attachment #144151 -
Flags: review?(jshin1987)
Attachment #144151 -
Flags: review?(daniel)
Assignee | ||
Updated•20 years ago
|
Attachment #144151 -
Flags: review?(jshin1987) → review?(smontagu)
Assignee | ||
Updated•20 years ago
|
Attachment #144151 -
Attachment description: patch (work in progress) → patch
Assignee | ||
Updated•20 years ago
|
Target Milestone: mozilla1.8alpha1 → mozilla1.8beta2
Comment 7•20 years ago
|
||
Comment on attachment 144151 [details] [diff] [review]
patch
This doesn't work correctly when deleting the last character in the testfield
with delete. i.e. in the testcase I delete the last character, and then place
the caret before the Deseret character and press delete.
It also doesn't seem to work at all in HTML editing.
Attachment #144151 -
Flags: review?(smontagu) → review-
Comment 8•20 years ago
|
||
(In reply to comment #7)
> (From update of attachment 144151 [details] [diff] [review] [edit])
> This doesn't work correctly when deleting the last character in the testfield
> with delete. i.e. in the testcase I delete the last character, and then place
> the caret before the Deseret character and press delete.
>
> It also doesn't seem to work at all in HTML editing.
>
Confirmed both of these. Whenever a plane 1 character is last in line,
backspace works but delete leaves a lone surrogate behind. In gmail you can
easily choose plain text or rich text. Rich text delete and backspace both
leave surrogates behind, but plain text works (except for the last character).
Shavian characters after hitting delete on the last one in the line:
Assignee | ||
Comment 9•20 years ago
|
||
This should fix the delete-at-last-character bug (I haven't tested it yet, but
it was a pretty obvious mistake in the patch).
I'm no longer interested enough in this bug to figure out where the relevant
HTML editing codepath is. If you'd prefer that the patch doesn't land without
HTML editing fixed as well, please reassign the bug to nobody@mozilla.org .
Attachment #144151 -
Attachment is obsolete: true
Attachment #187136 -
Flags: review?(smontagu)
Assignee | ||
Updated•20 years ago
|
Attachment #144151 -
Flags: superreview?(sfraser_bugs)
Comment 10•20 years ago
|
||
I'd like to see this fixed for html editing as well. Otherwise it's not totally
fixed. I could investigate it myself, but I'm not all up on C++ or Mozilla
coding. Can anyone grab this?
Assignee | ||
Updated•20 years ago
|
Target Milestone: mozilla1.8beta2 → Future
Comment 11•20 years ago
|
||
Comment on attachment 187136 [details] [diff] [review]
patch
r=smontagu. HTML editing can be a separate bug.
Attachment #187136 -
Flags: review?(smontagu) → review+
Assignee | ||
Updated•20 years ago
|
Attachment #187136 -
Flags: superreview?(roc)
Comment on attachment 187136 [details] [diff] [review]
patch
Can you change your &0xFC00 magic to use IS_HIGH_SURROGATE/IS_LOW_SURROGATE?
Other than that it looks fine
Attachment #187136 -
Flags: superreview?(roc) → superreview+
Assignee | ||
Comment 13•19 years ago
|
||
Attachment #187136 -
Attachment is obsolete: true
Assignee | ||
Comment 14•19 years ago
|
||
Fix checked in to trunk.
Filed bug 332636 for HTML, and also filed bug 332635.
Status: NEW → RESOLVED
Closed: 19 years ago
Resolution: --- → FIXED
Comment 15•18 years ago
|
||
*** Bug 346482 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
•