Skip to content

[Backport to release/10.0]: Clipboard.GetText(TextDataFormat.Rtf) does not retrieve RTF that lacks a null terminating character#14527

Open
SimonZhao888 wants to merge 1 commit into
dotnet:release/10.0from
SimonZhao888:backport_fix_issue_14458
Open

[Backport to release/10.0]: Clipboard.GetText(TextDataFormat.Rtf) does not retrieve RTF that lacks a null terminating character#14527
SimonZhao888 wants to merge 1 commit into
dotnet:release/10.0from
SimonZhao888:backport_fix_issue_14458

Conversation

@SimonZhao888
Copy link
Copy Markdown
Member

@SimonZhao888 SimonZhao888 commented May 7, 2026

Backport #14461 to release/10.0

Fixes #14458

In ReadStringFromHGLOBAL method requires a null terminator to determine string length. The format dispatch switch groups RTF (a registered format) with CF_TEXT and CF_OEMTEXT (standard formats), routing RTF through this null-termination-required path.Composition.NativeToManagedAdapterReadStringFromHGLOBAL()

When external applications (PowerPoint, etc.) place RTF on the clipboard without a null terminator — which is valid per the Windows clipboard spec — the method returns instead of the actual RTF content.string.Empty

Proposed changes

  • Add a new method ReadRegisteredFormatStringFromHGLOBAL(HGLOBAL, Encoding) to handle the CF_RTF format without a null terminator.

Customer Impact

  • Clipboard.GetText(TextDataFormat.Rtf) can retrieve RTF that lacks a null terminating character.

Regression?

Risk

  • Minimal

Test methodology

  • Manual testing
  • Unit test
Microsoft Reviewers: Open in CodeFlow

… not retrieve RTF that lacks a null terminating character
@codecov
Copy link
Copy Markdown

codecov Bot commented May 7, 2026

Codecov Report

❌ Patch coverage is 69.56522% with 7 lines in your changes missing coverage. Please review.
✅ Project coverage is 77.10915%. Comparing base (e02e4db) to head (af1f6dd).

Additional details and impacted files
@@                  Coverage Diff                   @@
##           release/10.0      #14527         +/-   ##
======================================================
+ Coverage      77.10887%   77.10915%   +0.00028%     
======================================================
  Files              3273        3273                 
  Lines            645062      645083         +21     
  Branches          47704       47708          +4     
======================================================
+ Hits             497400      497418         +18     
- Misses           143986      143989          +3     
  Partials           3676        3676                 
Flag Coverage Δ
Debug 77.10915% <69.56522%> (+0.00028%) ⬆️
integration 18.98920% <0.00000%> (+0.00035%) ⬆️
production 51.93139% <69.56522%> (+0.00245%) ⬆️
test 97.40991% <ø> (ø)
unit 49.34416% <69.56522%> (-0.00013%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@LeafShi1
Copy link
Copy Markdown
Member

LeafShi1 commented May 8, 2026

@SimonZhao888 For backport PRs, screenshots are not required, however, the "Test methodology," "Regression," and associated issues sections must be filled out in detail. Please refer to the PR #14121.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants