Closed Bug 1969820 Opened 6 months ago Closed 4 months ago

Pasting clipboard content in Firefox appends U+0000 null characters — occurs with Windows echo text | clip and PowerPro clip.set("text")

Categories

(Core :: Widget: Win32, defect)

Firefox 140
Desktop
Windows
defect

Tracking

()

RESOLVED FIXED
Tracking Status
firefox-esr115 --- unaffected
firefox-esr128 --- unaffected
firefox-esr140 --- unaffected
firefox139 --- unaffected
firefox140 + disabled
firefox141 + disabled

People

(Reporter: fraster, Assigned: handyman)

References

(Regression)

Details

(Keywords: regression)

Attachments

(1 file, 2 obsolete files)

Steps to reproduce:

in Windows execute
echo text|clip
or
in powerpro
clipset("text"

Actual results:

Paste the clipboard content into in input of url bar field using right-click → Paste then input field contains: "test" that includes 4 null bytes (0x00 0x00 0x00 0x00) as padding or terminator

Expected results:

input field contains: "test" without extra character

The Bugbug bot thinks this bug should belong to the 'Core::DOM: Copy & Paste and Drag & Drop' component, and is moving the bug to that component. Please correct in case you think the bot is wrong.

Component: Untriaged → DOM: Copy & Paste and Drag & Drop
Product: Firefox → Core
Status: UNCONFIRMED → NEW
Component: DOM: Copy & Paste and Drag & Drop → Widget: Win32
Ever confirmed: true
Keywords: regression
OS: Unspecified → Windows
Regressed by: 1966443
Hardware: Unspecified → Desktop

:handyman, since you are the author of the regressor, bug 1966443, could you take a look? Also, could you set the severity field?

For more information, please visit BugBot documentation.

Flags: needinfo?(davidp99)

It occour also in input html tag.

I missing echo in cmd dos:
echo test|clip

Assignee: nobody → davidp99
Flags: needinfo?(davidp99)
Severity: -- → S3

I'll just remove all of the null bytes at the end of the string (modulo Word's stray LF). This means that Windows will behave differently than Linux and Mac but I guess they don't have the same tradition of applications putting garbage on the clipboard. To recount:

  • The clipboard docs say that the clipboard data is terminated by a null byte, despite it having a separate length value. This belief was presumably the origin of the original code, and was therefore the cause of bug 1966443.
  • To fix that, we ignored docs and used the count, but removed the last char if it was null because "a lot of things were appending a null". So that was already a hack to get around bad clipboard contents.
  • That led to bug 1968267 -- Word was appending a null followed by a line feed to its contents. So we started also skipping that 2 byte combination as well.
  • This bug is about other apps (like the terminal piping output to the clipboard) adding streams of nulls to the end of their byte count. So we'll ignore that, too. We could probably use the solution that bug 1852790 comment 9 says Chrome uses, of removing all nulls, but that's further from our Linux and Mac implementations and is more severe.

We previously removed (0x00 0x0a | 0x00)? from the end of the contents.
We now remove (0x00 0x0a)? from the end, and any 0x00 found anywhere in the
contents.

We previously removed (0x00 0x0a|0x00)?. We now remove (0x00)*(0x00 0x0a)?.

We'll choose one of these.

Attachment #9492832 - Attachment is obsolete: true
Status: NEW → RESOLVED
Closed: 6 months ago
Resolution: --- → FIXED
Target Milestone: --- → 141 Branch

The patch landed in nightly and beta is affected.
:handyman, is this bug important enough to require an uplift?

For more information, please visit BugBot documentation.

Flags: needinfo?(davidp99)

We previously removed (0x00 0x0a|0x00)?. We now remove (0x00)*(0x00 0x0a)?.

Original Revision: https://phabricator.services.mozilla.com/D252588

Attachment #9493835 - Flags: approval-mozilla-beta?

firefox-beta Uplift Approval Request

  • User impact if declined: extra characters at the end of pasted strings from some Windows applications
  • Code covered by automated testing: no
  • Fix verified in Nightly: yes
  • Needs manual QE test: no
  • Steps to reproduce for manual QE testing: n/a
  • Risk associated with taking this patch: low
  • Explanation of risk level: Just stripping NULLs and the NULL/LF combo from the end of pasted strings
  • String changes made/needed: no
  • Is Android affected?: no
Attachment #9493835 - Flags: approval-mozilla-beta? → approval-mozilla-beta+
Pushed by agoloman@mozilla.com: https://github.com/mozilla-firefox/firefox/commit/4cbd07eea6ce https://hg.mozilla.org/integration/autoland/rev/bcb64d8b5ed5 Revert "Bug 1969820: Remove 0x00 0x0a and trailing nulls from clipboard r=win-reviewers,gstoll" as requested by Meehan.

Backed out from beta, as part of backing out the regressor Bug 1966443

Status: RESOLVED → REOPENED
Resolution: FIXED → ---
Target Milestone: 141 Branch → ---
Attachment #9493835 - Flags: approval-mozilla-release+
Flags: needinfo?(davidp99)
Attachment #9492834 - Attachment is obsolete: true

Fixed by backout

Status: REOPENED → RESOLVED
Closed: 6 months ago4 months ago
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: