Skip to content

fix(text): Harden UnicodeText malformed-text surrogate, indexing, and ICU bidi fallback#22697

Draft
agneszitte wants to merge 1 commit intomasterfrom
dev/agzi/fix-unicodetext-skia-index-guards
Draft

fix(text): Harden UnicodeText malformed-text surrogate, indexing, and ICU bidi fallback#22697
agneszitte wants to merge 1 commit intomasterfrom
dev/agzi/fix-unicodetext-skia-index-guards

Conversation

@agneszitte
Copy link
Contributor

@agneszitte agneszitte commented Feb 19, 2026

Related to https://github.com/unoplatform/kahua-private/issues/426

Summary

This PR hardens the Skia UnicodeText crash path for malformed-text scenarios, focusing on draw-time indexing, surrogate handling, and ICU/bidi setup. The goal is fail-safe rendering (no runtime exceptions) for the reported repro family.

Why

The repro hit ArgumentOutOfRangeException in UnicodeText.Draw with malformed surrogate/highlighter combinations. While fixing that path, related edge cases in bidi setup and draw-time index access were hardened to prevent equivalent crash outcomes.

What changed

  • Added draw-time bounds guards for:
    • highlighter slices traversal,
    • run-break traversal,
    • word-boundary/correction indexing,
    • line and line-metric index access.
  • Adjusted highlighter foreground/background fallback behavior to keep foreground optional and correctly fall back to run/default brushes.
  • Sanitized malformed surrogate code units to U+FFFD before shaping while preserving inline boundary behavior.
  • Added bidi fallback/retry behavior: if ubidi_setPara fails with embedding levels, retry without embedding levels.
  • Ensured bidi handle cleanup when ubidi_setPara fails in ICU interop.
  • Included ICU/bidi block formatting cleanup in the touched path.
  • Added targeted tests:
    • Unit tests for unpaired surrogate and oversized highlighter-range scenarios.
    • Skia runtime tests for unpaired surrogate rendering (with and without highlighter).

Local Validation

  • dotnet build src/Uno.UI/Uno.UI.Tests.csproj -c Debug -f net9.0
  • dotnet build src/Uno.UI.RuntimeTests/Uno.UI.RuntimeTests.Skia.csproj -c Debug
  • dotnet test src/Uno.UI.Tests/Uno.UI.Tests.csproj -c Debug -f net9.0 --filter "FullyQualifiedName~When_Text_Has_Unpaired_Surrogate|FullyQualifiedName~When_Highlighter_Range_Exceeds_Text"
  • Desktop and WASM repro smoke scans no longer match the original UnicodeText crash signatures.

Copilot AI review requested due to automatic review settings February 19, 2026 22:11
@github-actions github-actions bot added area/skia ✏️ Categorizes an issue or PR as relevant to Skia area/automation Categorizes an issue or PR as relevant to project automation labels Feb 19, 2026
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Hardens Skia UnicodeText shaping/drawing to avoid crashes on malformed Unicode input and out-of-range highlighter/run scenarios, and adds coverage to ensure those cases don’t throw during layout/rendering.

Changes:

  • Sanitizes malformed UTF-16 (unpaired surrogates) and adds an ICU BiDi setup fallback path.
  • Adds multiple draw-time bounds guards around highlighter slices, run breaks, word boundaries, and line metric lookups.
  • Adds unit tests and Skia runtime tests covering malformed text and overlong highlighter ranges.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 4 comments.

File Description
src/Uno.UI/UI/Xaml/Documents/UnicodeText.skia.cs Adds surrogate sanitization, BiDi fallback, and defensive bounds checks in Draw and word-boundary generation.
src/Uno.UI.Tests/Windows_UI_XAML_Controls/TextBlockTests/Given_TextBlock.cs Adds unit tests for malformed surrogate text and out-of-range highlighter ranges.
src/Uno.UI.RuntimeTests/Tests/Windows_UI_Xaml_Controls/Given_TextBlock.cs Adds Skia-only rendering tests to ensure no crashes with unpaired surrogates (with/without highlighters).

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 4 out of 4 changed files in this pull request and generated no new comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@agneszitte agneszitte changed the title fix: prevent Skia UnicodeText draw crashes on malformed text fix(text): Harden Skia UnicodeText malformed-text and highlight indexing paths Feb 19, 2026
@unodevops
Copy link
Contributor

🤖 Your WebAssembly Skia Sample App stage site is ready! Visit it here: https://unowasmprstaging.z20.web.core.windows.net/pr-22697/wasm-skia-net9/index.html

@nventive-devops
Copy link
Contributor

The build 197277 found UI Test snapshots differences: android-28-net9: 19, android-28-net9-Snap: 23, ios: 3, ios-Snap: 40, skia-linux-screenshots: 903, skia-windows-screenshots: 596, wasm: 110, wasm-automated-net10.0-WinUI-Benchmarks-automated: 0, wasm-automated-net10.0-WinUI-Default-automated: 14, wasm-automated-net10.0-WinUI-RuntimeTests-0: 0, wasm-automated-net10.0-WinUI-RuntimeTests-1: 0, wasm-automated-net10.0-WinUI-RuntimeTests-2: 0

Details
  • android-28-net9: 19 changed over 825

    🚨🚨 Comparison Details (first 20) 🚨🚨
    • Detereminate_ProgressRing_Validation75_[#FF0000_#008000_#008000_#008000]_Progress-Ring-Value-75
    • ProgressRing_IsEnabled_Running_UITests_Windows_UI_Xaml_Controls_ProgressRing_WindowsProgressRing_GH1220
    • ProgressRing_Visibility_Collapsed_UITests_Windows_UI_Xaml_Controls_ProgressRing_WindowsProgressRing_GH1220
    • WebView_NavigateToAnchor_Initial
    • When_NoSelectionWithItemClick_Then_PointersEvents_UITests_Windows_UI_Xaml_Controls_ListView_ListView_Selection_Pointers
    • Popup_PlacementTest_2Default_HTVL_Uno_UI_Samples_Content_UITests_Popup_Popup_HVAlignments
    • Popup_PlacementTest_3Default_HCVC_Uno_UI_Samples_Content_UITests_Popup_Popup_HVAlignments
    • SequentialAnimations_SamplesApp_Windows_UI_Xaml_Media_Animation_SequentialAnimationsPage
    • When_SingleSelectionWithItemClick_Then_PointersEvents_UITests_Windows_UI_Xaml_Controls_ListView_ListView_Selection_Pointers
    • When_SingleSelectionWithoutItemClick_Then_PointersEvents_UITests_Windows_UI_Xaml_Controls_ListView_ListView_Selection_Pointers
    • DecimalFormatterTest_UITests_Shared_Microsoft_UI_Xaml_Controls_NumberBoxTests_NumberBoxPage
    • Detereminate_ProgressRing_Validation25_[#FF0000_#008000_#FF0000_#FF0000]_Progress-Ring-Value-25
    • Detereminate_ProgressRing_Validation50_[#FF0000_#008000_#008000_#FF0000]_Progress-Ring-Value-50
    • FlyoutTest_When_NoOverlayInputPassThroughElement_Then_DontPassThrough_woOff_UITests_Shared_Windows_UI_Xaml_Controls_Flyout_Flyout_OverlayInputPassThroughElement
    • When_ExtendedSelectionWithoutItemClick_Then_PointersEvents_UITests_Windows_UI_Xaml_Controls_ListView_ListView_Selection_Pointers
    • When_Parent_PointerMoved_After_drag_on_non-scrolling_ScrollViewer
    • When_Parent_PointerMoved_After_drag_on_ScrollViewer_-_touch
    • NativeCommandBar_Size_Uno_UI_Samples_Content_UITests_CommandBar_CommandBar_Dynamic
    • UpDownEnabledTest_UITests_Shared_Microsoft_UI_Xaml_Controls_NumberBoxTests_NumberBoxPage
  • android-28-net9-Snap: 23 changed over 1064

    🚨🚨 Comparison Details (first 20) 🚨🚨
    • MediaPlayerElement_Mini_player_UITests_Shared_Windows_UI_Xaml_Controls_MediaPlayerElement_MediaPlayerElement_Minimal
    • MediaPlayerElement_Using_ogg_UITests_Shared_Windows_UI_Xaml_Controls_MediaPlayerElement_MediaPlayerElement_Ogg_Extension
    • RatingControl_UITests_Microsoft_UI_Xaml_Controls_RatingControlTests_RatingControlPage_UITests_Microsoft_UI_Xaml_Controls_RatingControlTests_RatingControlPage
    • SwipeControl_MUXControlsTestApp_SwipeControlPage2_MUXControlsTestApp_SwipeControlPage2
    • CommandBarFlyout_MUXControlsTestApp_CommandBarFlyoutPage_MUXControlsTestApp_CommandBarFlyoutPage
    • Default_Uno_UI_Samples_Content_UITests_WebView_WebView_AnchorNavigation_Uno_UI_Samples_Content_UITests_WebView_WebView_AnchorNavigation
    • ListView_ListViewSelectedItems_SamplesApp_Windows_UI_Xaml_Controls_ListView_ListViewSelectedItems
    • Pickers_UITests_Windows_UI_Xaml_Controls_CalendarView_CalendarView_Theming_UITests_Windows_UI_Xaml_Controls_CalendarView_CalendarView_Theming
    • CommandBar_Examples_Uno_UI_Samples_Content_UITests_CommandBar_CommandBar_Examples
    • TextBlock_UITests_Shared_Windows_UI_Xaml_Controls_TextBlockControl_TextBlock_Layout_UITests_Shared_Windows_UI_Xaml_Controls_TextBlockControl_TextBlock_Layout
    • Scrolling_MUXControlsTestApp_ScrollViewDynamicPage_MUXControlsTestApp_ScrollViewDynamicPage
    • Scrolling_MUXControlsTestApp_ScrollViewKeyboardAndGamepadNavigationPage_MUXControlsTestApp_ScrollViewKeyboardAndGamepadNavigationPage
    • UIElement_TransformToVisual_Simple_UITests_Shared_Windows_UI_Xaml_UIElementTests_TransformToVisual_Simple
    • TeachingTip_UITests_Microsoft_UI_Xaml_Controls_TeachingTipTests_TeachingTipPage_UITests_Microsoft_UI_Xaml_Controls_TeachingTipTests_TeachingTipPage
    • Gesture_Recognizer_Pointer_Events_test_bench_UITests_Shared_Windows_UI_Input_GestureRecognizer_PointersEvents
    • MUX_UITests_Shared_Microsoft_UI_Xaml_Controls_TreeViewTests_TreeViewPage_UITests_Shared_Microsoft_UI_Xaml_Controls_TreeViewTests_TreeViewPage
    • WebView_UITests_Microsoft_UI_Xaml_Controls_WebView2Tests_WebView2_NavigationProperties_UITests_Microsoft_UI_Xaml_Controls_WebView2Tests_WebView2_NavigationProperties
    • Image_UITests_Windows_UI_Xaml_Controls_ImageTests_SvgImageSource_NoSize_UITests_Windows_UI_Xaml_Controls_ImageTests_SvgImageSource_NoSize
    • MUX_NumberBox_UITests_Shared_Microsoft_UI_Xaml_Controls_NumberBoxTests_NumberBoxPage
    • TabView_MUXControlsTestApp_TabViewPage_MUXControlsTestApp_TabViewPage
  • ios: 3 changed over 256

    🚨🚨 Comparison Details (first 20) 🚨🚨
    • ProgressRing_IsEnabled_Running_UITests_Windows_UI_Xaml_Controls_ProgressRing_WindowsProgressRing_GH1220
    • ProgressRing_Visibility_Collapsed_UITests_Windows_UI_Xaml_Controls_ProgressRing_WindowsProgressRing_GH1220
    • SequentialAnimations_SamplesApp_Windows_UI_Xaml_Media_Animation_SequentialAnimationsPage
  • ios-Snap: 40 changed over 983

    🚨🚨 Comparison Details (first 20) 🚨🚨
    • Brushes_PathImageBrushfill_Uno_UI_Samples_UITests_ImageBrushTestControl_PathImageBrushfill
    • Brushes_PanelImageBrush_Uno_UI_Samples_UITests_ImageBrushTestControl_PanelImageBrush
    • Brushes_Uno_UI_Samples_Samples_Shared_Content_UITests_ImageBrushInList_Uno_UI_Samples_Samples_Shared_Content_UITests_ImageBrushInList
    • Icons_UITests_Microsoft_UI_Xaml_Controls_ImageIconTests_ImageIconPage_UITests_Microsoft_UI_Xaml_Controls_ImageIconTests_ImageIconPage
    • Icons_UITests_Shared_Windows_UI_Xaml_Controls_BitmapIconTests_BitmapIcon_Foreground_UITests_Shared_Windows_UI_Xaml_Controls_BitmapIconTests_BitmapIcon_Foreground
    • Image_UITests_Windows_UI_Xaml_Controls_ImageTests_Image_Formats_UITests_Windows_UI_Xaml_Controls_ImageTests_Image_Formats
    • NavigationView_NavigationViewSample_SamplesApp_Samples_NavigationViewSample_NavigationViewSample
    • Brushes_ImageBrushStretch2_Uno_UI_Samples_UITests_ImageBrushTestControl_ImageBrushStretch2
    • ColorPicker_ColorPickerSample_UITests_Microsoft_UI_Xaml_Controls_ColorPickerTests_ColorPickerSample
    • TextBlock_UITests_Windows_UI_Xaml_Controls_TextBlockControl_TextBlock_RelativeTextSize_UITests_Windows_UI_Xaml_Controls_TextBlockControl_TextBlock_RelativeTextSize
    • TextBox_TextBox_Disabled_State_Uno_UI_Samples_Content_UITests_TextBoxControl_TextBox_Disabled_State
    • Brushes_BorderImageBrush_Uno_UI_Samples_UITests_ImageBrushTestControl_BorderImageBrush
    • Image_Uno_UI_Samples_UITests_Image_Image_Stretch_Alignment_Equal_Uno_UI_Samples_UITests_Image_Image_Stretch_Alignment_Equal
    • Image_Uno_UI_Samples_UITests_Image_Image_Stretch_Alignment_Smaller_Uno_UI_Samples_UITests_Image_Image_Stretch_Alignment_Smaller
    • Image_Uno_UI_Samples_UITests_Image_Image_Stretch_Alignment_Taller_Uno_UI_Samples_UITests_Image_Image_Stretch_Alignment_Taller
    • Performance_UITests_Windows_UI_Xaml_Performance_Performance_1000ButtonsContinuousRendering_UITests_Windows_UI_Xaml_Performance_Performance_1000ButtonsContinuousRendering
    • Image_Uno_UI_Samples_UITests_Image_Image_Stretch_Alignment_Wider_Uno_UI_Samples_UITests_Image_Image_Stretch_Alignment_Wider
    • Image_Uno_UI_Samples_UITests_Image_Image_Stretch_Uno_UI_Samples_UITests_Image_Image_Stretch
    • Buttons_Custom_Button_With_ContentTemplate_Uno_UI_Samples_Content_UITests_ButtonTestsControl_Custom_Button_With_ContentTemplate
    • Scrolling_MUXControlsTestApp_ScrollViewDynamicPage_MUXControlsTestApp_ScrollViewDynamicPage
  • skia-linux-screenshots: 903 changed over 2306

    🚨🚨 Comparison Details (first 20) 🚨🚨
    • AutoSuggestBox_SoftKeboard.png-dark
    • AutoSuggestBox_SoftKeboard.png
    • BreadcrumbBarPage.png-dark
    • BreadcrumbBarPage.png
    • CalendarView_Theming.png-dark
    • CalendarView_Theming.png
    • ColorPickerSample.png
    • ComboBox_ComboBoxItem_Selection.png-dark
    • CommandBar_Background.png
    • CommandBar_LongTitle_Navigation.png-dark
    • ContentDialog_Async.png
    • ContentDialog_Closing.png-dark
    • ContentDialog_Closing.png
    • ContentDialog_ComboBox.png-dark
    • DoubleAnimation_BeginTime.png-dark
    • DoubleAnimation_BeginTime.png
    • FlipView_Images.png-dark
    • FlipView_Images.png
    • Grid_ZIndex.png-dark
    • Grid_ZIndex.png
  • skia-windows-screenshots: 596 changed over 2310

    🚨🚨 Comparison Details (first 20) 🚨🚨
    • Accessibility_ScreenReader.png
    • AppBarButtonTest.png-dark
    • AppBarButtonWithIconTest.png
    • ArcSegment.png-dark
    • ArcSegment.png
    • AutoSizedTopLeft.png-dark
    • BadgeNotificationTests.png-dark
    • Basics_Automated.png
    • CalendarView_Theming.png
    • CameraCaptureUISample.png-dark
    • CameraCaptureUISample.png
    • Display.DisplayRequest.png-dark
    • Display.DisplayRequest.png
    • DynamicBrushes_On_Shapes.png-dark
    • DynamicBrushes_On_Shapes.png
    • Accessibility_ScreenReader.png-dark
    • AppBarButtonWithIconTest.png-dark
    • AppBarToggleButtonTest.png-dark
    • AutoSizedTopLeft.png
    • BasicAutoSuggestBox.png-dark
  • wasm: 110 changed over 1063

    🚨🚨 Comparison Details (first 20) 🚨🚨
    • MUXControlsTestApp.TextCommandBarFlyoutPage
    • UITests.Shared.Windows_UI_Xaml_Controls.TextBoxControl.TextBox_Binding_Null
    • UITests.Windows_ApplicationModel.DataTransfer.DataTransferManagerTests
    • UITests.Windows_UI_Xaml.Performance.Performance_1000ButtonsContinuousRendering
    • UITests.Windows_UI_Xaml_Controls.Slider.Slider_Header
    • UITests.Windows_UI_Xaml_Controls.SplitView.SplitViewClip
    • GenericApp.Views.Samples.Shared.Content.UITests.GridViewMultipleSelectionMode
    • SamplesApp.Windows_UI_Xaml_Controls.ListView.ListView_ItemContainerStyleSelector
    • UITests.Shared.Windows_UI_Xaml_Controls.PasswordBoxTests.PasswordBoxPage
    • UITests.Uno_Web.Http.CookieManagerTests
    • UITests.Windows_UI_Xaml_Controls.CommandBar.CommandBar_Native_With_TextBox
    • UITests.Windows_UI_Xaml_Controls.TextBox.TextBox_VerticalAlignment
    • MUXControlsTestApp.SelectorBarPage
    • SamplesApp.Wasm.Windows_UI_Xaml_Controls.ComboBox.ComboBox_DropDownWidth
    • MUXControlsTestApp.ExtraCommandBarFlyoutPage
    • SamplesApp.Microsoft_UI_Xaml_Controls.WebView2Tests.WebView2_AnchorNavigation
    • SamplesApp.Windows_UI_Xaml_Controls.ListView.ListView_Expandable_Item
    • SamplesApp.Windows_UI_Xaml.Clipping.DoubleAnimationClipping
    • SamplesApp.Windows_UI_Xaml_Controls.ListView.ListView_Expandable_Item_Large
    • SamplesApp.Windows_UI_Xaml_Controls.ListView.ListViewSelectedItems
  • wasm-automated-net10.0-WinUI-Benchmarks-automated: 0 changed over 1

  • wasm-automated-net10.0-WinUI-Default-automated: 14 changed over 877

    🚨🚨 Comparison Details (first 20) 🚨🚨
    • Default_StrokeThickness_MyPolyline
    • Default_StrokeThickness_MyLine
    • Default_StrokeThickness_MyRect
    • SequentialAnimations_SamplesApp_Windows_UI_Xaml_Media_Animation_SequentialAnimationsPage
    • TestProgressRing_InitialState_UITests_Microsoft_UI_Xaml_Controls_ProgressRing_WinUIProgressRing_Features
    • ListView_SelectedItems_SamplesApp_Windows_UI_Xaml_Controls_ListView_ListViewSelectedItems
    • When_SingleSelectionWithItemClick_Then_PointersEvents_UITests_Windows_UI_Xaml_Controls_ListView_ListView_Selection_Pointers
    • When_NoSelectionWithItemClick_Then_PointersEvents_UITests_Windows_UI_Xaml_Controls_ListView_ListView_Selection_Pointers
    • Default_StrokeThickness_MyEllipse
    • Default_StrokeThickness_MyPath
    • When_MultipleSelectionWithoutItemClick_Then_PointersEvents_UITests_Windows_UI_Xaml_Controls_ListView_ListView_Selection_Pointers
    • When_StretchAndAlignmentNone_ImageBrush-50-50-None-XLeft-YBottom
    • Default_StrokeThickness_MyPolygon
    • When_ExtendedSelectionWithoutItemClick_Then_PointersEvents_UITests_Windows_UI_Xaml_Controls_ListView_ListView_Selection_Pointers
  • wasm-automated-net10.0-WinUI-RuntimeTests-0: 0 changed over 1

  • wasm-automated-net10.0-WinUI-RuntimeTests-1: 0 changed over 1

  • wasm-automated-net10.0-WinUI-RuntimeTests-2: 0 changed over 1

@unodevops
Copy link
Contributor

⚠️⚠️ The build 197277 has failed on Uno.UI - CI.

@unodevops
Copy link
Contributor

🤖 Your WebAssembly Skia Sample App stage site is ready! Visit it here: https://unowasmprstaging.z20.web.core.windows.net/pr-22697/wasm-skia-net9/index.html

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 4 out of 4 changed files in this pull request and generated no new comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@agneszitte agneszitte force-pushed the dev/agzi/fix-unicodetext-skia-index-guards branch from 3460940 to 5e06d71 Compare February 20, 2026 04:36
@agneszitte agneszitte changed the title fix(text): Harden Skia UnicodeText malformed-text and highlight indexing paths fix(text): Harden UnicodeText surrogate, indexing, and ICU bidi fallback Feb 20, 2026
@agneszitte agneszitte changed the title fix(text): Harden UnicodeText surrogate, indexing, and ICU bidi fallback fix(text): Harden UnicodeText malformed-text surrogate, indexing, and ICU bidi fallback Feb 20, 2026
@agneszitte agneszitte requested a review from Copilot February 20, 2026 04:39
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 4 out of 4 changed files in this pull request and generated no new comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@agneszitte agneszitte force-pushed the dev/agzi/fix-unicodetext-skia-index-guards branch 2 times, most recently from 6f8b634 to 4e78893 Compare February 20, 2026 05:05
Copilot AI review requested due to automatic review settings February 20, 2026 05:05
- Add defensive draw-time bounds checks for highlighter/run-break/word-boundary and line metric indexing.

- Sanitize malformed UTF-16 surrogate units to U+FFFD before shaping.

- Retry ICU ubidi_setPara without embedding levels when explicit levels fail, with bidi handle cleanup.

- Keep/update unit and Skia runtime regression coverage for malformed surrogate and highlighter-range scenarios.
@agneszitte agneszitte force-pushed the dev/agzi/fix-unicodetext-skia-index-guards branch from 4e78893 to 131ed62 Compare February 20, 2026 05:07
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +1368 to +1371
var c = chars[index];
if (char.IsHighSurrogate(c))
{
if (index + 1 < chars.Length && char.IsLowSurrogate(chars[index + 1]))
Copy link

Copilot AI Feb 20, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The sanitization logic for valid surrogate pairs is incorrect. When a valid high-low surrogate pair is detected (line 1368), the code increments by 1 (line 1370) and continues. On the next loop iteration, index will point to the low surrogate, which will match the condition at line 1377 and be incorrectly replaced with U+FFFD.

The fix is to increment by 2 instead of 1 on line 1370, so the loop skips both characters in the valid pair: index += 2;

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/automation Categorizes an issue or PR as relevant to project automation area/skia ✏️ Categorizes an issue or PR as relevant to Skia

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants

Comments