Closed Bug 1599318 Opened 5 years ago Closed 5 years ago

HTML textarea accepts \r character, when it should be replaced with \n

Categories

(Core :: DOM: Editor, defect, P2)

defect

Tracking

()

RESOLVED FIXED
mozilla72
Tracking Status
firefox-esr68 --- unaffected
firefox70 --- unaffected
firefox71 --- unaffected
firefox72 + fixed

People

(Reporter: darktrojan, Assigned: masayuki)

References

(Regression)

Details

(Keywords: regression)

Attachments

(2 files)

When keyboard events fire "\r" at a textarea, the value could include the \r, when they should instead have a \n. Or at least, that's what I understand is supposed to happen.

Test case coming up.

This is a copy of dom/tests/mochitest/keyhandling/test_textarea.html modified to show the error, and moved somewhere so that it runs on Linux.

Assignee: nobody → masayuki
Status: NEW → ASSIGNED
Keywords: regression
OS: Unspecified → All
Priority: -- → P1
Hardware: Unspecified → All
Version: unspecified → Trunk

I cannot reproduce this bug with usual DOM operation and \r inputting key event is never fired if the source is native key event because ASCII control characters are replaced with normal characters which are inputted without modifier key. So that this is an edge case.

Priority: P1 → P2
Blocks: 1599330

[Tracking Requested - why for this release]: I'm actually not sure we need to track. That is, it's not clear to me whether the web can encounter this behavior, per comment 2....

Well, anyway, a patch is coming.

Starting from bug 1597679, HTMLTextAreaElement::GetValueInternal() stops
converting \r\n and \r with \n because it may be in hot path and the scan
cost of \r in nsContentUtils::PlatformToDOMLineBreaks() is redundant in
most cases.

However, there are still some paths to input \r. This patch makes them
call nsContentUtils::PlatformToDOMLineBreaks() if they have not done it.

Pushed by masayuki@d-toybox.com:
https://hg.mozilla.org/integration/autoland/rev/51ba531b4ad5
`TextEditor` shouldn't put `\r` into its anonymous text node r=m_kato
Status: ASSIGNED → RESOLVED
Closed: 5 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla72
Has Regression Range: --- → yes
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: