Skip to content

fix: HTML parsing/normalization flow adjustments - #815

Draft
hejsztynx wants to merge 7 commits into
mainfrom
@ksienkiewicz/fix-ios-initial-html-processing-flow
Draft

hejsztynx wants to merge 7 commits into
mainfrom
@ksienkiewicz/fix-ios-initial-html-processing-flow

Conversation

@hejsztynx

@hejsztynx hejsztynx commented Oct 14, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

Closes #811

This PR addresses a couple of iOS issues:

  • we had an undesirable html length check, which caused a string below the length of 13 to not be parsed as HTML, e.g. <p>a</p>
  • if you passed </body>123<body>, where the closing and opening body tags are swapped, the whole app crashed
  • in case of an exception during parsing, we now catch that exception and fall back to a plain text insertion. Such approach was already used in EnrichedText parser, but not in the input one

Aside from that, it introduces a modification into our normalizer flow. Now it's consistent across all three platforms and works as follows:

  • if the value is wrapped with <html></html> tags, we strip them and extract html from the <body> tag, if there is one
  • now we look at the useHtmlNormalizer flag, and we normalize the current html if needed
  • at last, we try to parse our processed html

Previously the main issue was that even with useHtmlNormalizer set to true, we didn't normalize the html when it was wrapped with <html> tags - we want to always normalize it, as <html> tags are not a guarantee of any sort that the structure is ours.

This PR also introduces one fix, caught by an android regression test. Empty <codeblock></codeblock> was normalized into <codeblock><p></p></codeblock>, which is something that android's parser does not handle correctly, so normalizer was adjusted - <p></p> is not emitted when empty. The iOS behavior effectively has not changed in this manner.

I've run all the e2e tests, they pass.

Test Plan

Try out the cases I listed above on iOS, with both EnrichedTextInput and EnrichedText components. Run the e2e tests on android/ios, experiment with html parsing, test the html round-trip with useHtmlNormalizer set to true and false.

Screenshots / Videos

iOS bugs that were present:

Screen.Recording.2026-10-14.at.17.02.45.mov
Screen.Recording.2026-10-14.at.17.03.58.mov

Compatibility

OS Implemented
iOS ✅
Android ✅
Web ✅

Checklist

  • E2E tests are passing
  • Required E2E tests have been added (if applicable)

Copilot AI balanced review requested due to automatic review settings October 14, 2026 15:05

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 Changes recommended

The fixed failure modes lack regression coverage in the existing iOS Maestro suite.

1 open finding
What changed in this PR

Improves iOS HTML preprocessing resilience and fallback behavior.

Changes:

  • Supports short HTML strings.
  • Safely handles reversed body tags.
  • Catches preprocessing failures and preserves raw input.
File Description
ios/​inputHtmlParser/​InputHtmlParser.mm Adds exception handling.
ios/​htmlParser/​HtmlParser.mm Fixes length and body-range parsing.
ios/​EnrichedTextInputView.mm Guards failed preprocessing.

🧠 Review effort: Balanced


💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread ios/htmlParser/HtmlParser.mm
Comment thread ios/htmlParser/HtmlParser.mm
Comment thread ios/htmlParser/HtmlParser.mm Outdated
@hejsztynx
hejsztynx marked this pull request as draft October 15, 2026 10:36
@hejsztynx
hejsztynx force-pushed the @ksienkiewicz/fix-ios-initial-html-processing-flow branch 2 times, most recently from 5287dc6 to e1dbbf2 Compare October 22, 2026 10:23
@hejsztynx
hejsztynx force-pushed the @ksienkiewicz/fix-ios-initial-html-processing-flow branch from e1dbbf2 to 97a8e3c Compare October 22, 2026 10:24
@hejsztynx hejsztynx changed the title fix(ios): initial HTML parsing failures fix: HTML parsing/normalization flow adjustments Oct 22, 2026
@hejsztynx
hejsztynx requested a balanced review from Copilot October 22, 2026 10:44

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 Changes recommended

Unresolved crash and content-corruption risks, together with inconsistent iOS fragment parsing, block approval.

5 open issues
1 resolved since last review

Review effort: Balanced

Comment thread ios/htmlParser/HtmlParser.mm
Comment thread ios/htmlParser/HtmlParser.mm
// Run through the Gumbo-based normalizer to convert arbitrary HTML
// into our canonical tag subset.
NSString *toNormalize = fixedHtml != nullptr ? fixedHtml : html;
NSString *normalized = [self normalizeExternalHtml:toNormalize];
Comment thread src/web/normalization/htmlWrapperExtractor.ts

This branch has not been deployed

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[iOS] Tags not parsed on iOS below a certain string length

3 participants