Repository navigation
fix(android): Escape HTML attribute values - #865
Merged
Merged
Conversation
Link href, image src and mention attributes were written to HTML without escaping, so a value containing `"` or `&` (e.g. https://example.com/a&b"c) broke out of the attribute. Escape them the same way span style attributes already were, matching the iOS fix from #849. Fixes the link_href_attribute_escaping e2e flow on Android. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_011B8KVetRzS7b2SUyxrrhgS
Contributor
There was a problem hiding this comment.
🟢 Approval recommended
No active review issues are recorded for the Android HTML attribute-escaping changes.
No open issues 🎉
What changed in this PR
This PR escapes HTML attribute values during Android serialization, aligning behavior with the iOS changes in #849 and preventing values from breaking out of double-quoted attributes.
Changes:
- Adds a shared helper to escape
&,<,>and". - Applies escaping to link URLs, image sources, and mention attribute values.
- Reuses the helper for existing span-style escaping.
| File | Description |
|---|---|
android/src/main/java/com/swmansion/enriched/common/parser/EnrichedParser.java |
Centralizes attribute escaping and applies it to links, images, mentions, and span styles. |
Review effort: Balanced
exploIF
approved these changes
Nov 19, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Android was writing link
href, imagesrcand mention attribute values into the output HTML without escaping them. A value containing"or&(e.g.https://example.com/a&b"c) broke out of its attribute, so the HTML came out invalid and attributes could be injected. Because of this, thelink_href_attribute_escapinge2e flow added in #849 fails on Android.This brings Android in line with iOS, which got the same escaping in #849.
Changes
escapeAttribute()helper toEnrichedParserthat escapes&,<,>and".href, imagesrc, and mentiontext,indicatorand custom attributes.styleattribute already escaped these characters inline; it now uses the same helper.Reading HTML back in needs no changes, because the parser already decodes entities in attribute values, so escaped values come back as the original strings.
Test Plan
yarn test:e2e:android .maestro/enrichedInput/flows/link_href_attribute_escaping.yaml. The output now containshref="https://example.com/a&b"c", and setting that HTML again gives the same output (no double escaping)."and&, check the HTML output, then set that HTML back and check that the link's URL is unchanged.Compatibility
Checklist