Skip to content

fix: normalizer keeping empty src - #743

Merged
hejsztynx merged 1 commit into
mainfrom
@ksienkiewicz/fix-normalizer-img-src
Aug 5, 2026
Merged

fix: normalizer keeping empty src#743
hejsztynx merged 1 commit into
mainfrom
@ksienkiewicz/fix-normalizer-img-src

Conversation

@hejsztynx

Copy link
Copy Markdown
Collaborator

Summary

Now if no src attribute is present inside <img>, the normalizer adds an empty one - src="". This is done for the sake of structural consistency, which also fixed a couple of issues:

  • on web, when you inserted an <img> with no src attribute, the inline image would get dropped, whereas we want to still display the placeholder
  • on iOS and Android, the parser would break if passed an empty src or no at all

Test Plan

Set input's value with a <img> tag and a src="", `src="something" and no attribute at all. Each case should have the same effect - a placeholder inline image.

Screenshots / Videos

iOS

Before:

Screen.Recording.2026-08-05.at.10.28.02.mov

After:

Screen.Recording.2026-08-05.at.10.36.36.mov

Compatibility

OS Implemented
iOS
Android
Web

Checklist

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

@hejsztynx
hejsztynx requested a review from Copilot August 5, 2026 08:38
@hejsztynx
hejsztynx marked this pull request as draft August 5, 2026 08:38

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.

Pull request overview

This PR updates the HTML normalization/parsing pipeline so <img> tags always carry a src attribute, defaulting to an empty value when missing, enabling consistent placeholder rendering and avoiding native parser breakage.

Changes:

  • Web normalizer now emits src="" for <img> when src is missing (or empty).
  • iOS parser regex updated to accept empty src values (src="").
  • Added/updated unit tests in both web and C++ normalization paths to cover missing/empty src.

Reviewed changes

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

Show a summary per file
File Description
src/web/normalization/htmlNormalizer.ts Ensures <img> always serializes with src="" when missing/empty.
src/web/tests/htmlNormalizer.test.ts Adds test cases for <img> with missing src and src="".
ios/htmlParser/HtmlParser.mm Allows src="" to be parsed by relaxing the src regex capture.
cpp/parser/GumboNormalizer.c Emits src="" for <img> when src is missing/empty.
cpp/tests/GumboParserTest.cpp Adds coverage for <img> normalization with missing/empty src.

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

@hejsztynx
hejsztynx marked this pull request as ready for review August 5, 2026 08:54

@kacperzolkiewski kacperzolkiewski left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

LGTM

@hejsztynx
hejsztynx merged commit 42fb60e into main Aug 5, 2026
10 checks passed
@hejsztynx
hejsztynx deleted the @ksienkiewicz/fix-normalizer-img-src branch August 5, 2026 10:40
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.

3 participants