Skip to content

fix: HTML parser handling img attributes with float values#685

Merged
hejsztynx merged 4 commits into
mainfrom
@ksienkiewicz/fix-android-normalizer-number-parsing
Jul 9, 2026
Merged

fix: HTML parser handling img attributes with float values#685
hejsztynx merged 4 commits into
mainfrom
@ksienkiewicz/fix-android-normalizer-number-parsing

Conversation

@hejsztynx

@hejsztynx hejsztynx commented Jul 8, 2026

Copy link
Copy Markdown
Collaborator

Summary

HTML parser on Android explicitly tired to parse <img> dimension attributes height and width as Integer, with no exception caught, which caused the whole parser to bail. Web and iOS outputs HTML with float dimensions, so using that HTML in Android would break the input.

Also I got rid of the core cause of this issue - made the iOS parser function the same as the Android one and they both now converts both dimension attributes to integer values. #688

Testing

Example HTML that would break if used in Set input's value

<html>
<p>Asd<img src="asd" width="30.000000" height="30.000000"/></p>
</html>

Screenshots / Videos

iOS on the left, Android on the right

Before:

img-parsing2.mov

After:

img-parsing2-after.mov

Compatibility

OS Implemented
iOS
Android
Web

Checklist

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

Copilot AI review requested due to automatic review settings July 8, 2026 10:45

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

Fixes a crash in the Android HTML parser when <img> width/height attributes contain float values (e.g. 30.000000), improving cross-platform HTML compatibility (Web/iOS → Android).

Changes:

  • Replace Integer.parseInt for <img> dimensions with a safer float-tolerant parsing helper.
  • Add parseDimension(String) to convert float-like dimension strings into int values without throwing.

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

@hejsztynx hejsztynx marked this pull request as draft July 8, 2026 11:20
@hejsztynx hejsztynx marked this pull request as ready for review July 8, 2026 11:47
@kacperzolkiewski

kacperzolkiewski commented Jul 8, 2026

Copy link
Copy Markdown
Collaborator

I think we should improve HTML generation on iOS in a separate PR and make sure integer values are displayed without the .000000 suffix.

@hejsztynx hejsztynx marked this pull request as draft July 8, 2026 15:51
# Summary

Now the `img` attributes are converted to integer. It's truthful to
official HTML5 specifications, where `width` and `height` should be
integer values and the floating point in HTML could be destructive,
which could produce a similar issue as in
#685

## Screenshots

When adding an image via modal with `height` and `width` set to `30`

Before:

<img width="341" height="331" alt="image"
src="https://github.com/user-attachments/assets/f905c3c9-7f6e-4bb7-86ec-235e9668c37c"
/>

After:

<img width="334" height="326" alt="image"
src="https://github.com/user-attachments/assets/2c1dae24-693a-4c9a-84cf-418865837a7e"
/>


## Compatibility

| OS      | Implemented |
| ------- | :---------: |
| iOS     |    ✅     |
| Android |    ❌     |
| Web     |    ❌     |

## Checklist

- [ ] E2E tests are passing
- [ ] Required E2E tests have been added (if applicable)
@hejsztynx hejsztynx marked this pull request as ready for review July 8, 2026 15:56
@hejsztynx

Copy link
Copy Markdown
Collaborator Author

I think we should improve HTML generation on iOS in a separate PR and make sure integer values are displayed without the .000000 suffix.

that's a oneline fix, and in a shared scope, I'll introduce it in this PR

@hejsztynx hejsztynx changed the title fix(android): Android HTML parser throws on attributes with float values fix: HTML parser handling img attributes with float values Jul 8, 2026
Comment thread android/src/main/java/com/swmansion/enriched/common/parser/EnrichedParser.java Outdated
@hejsztynx hejsztynx merged commit 6da8f0d into main Jul 9, 2026
8 checks passed
@hejsztynx hejsztynx deleted the @ksienkiewicz/fix-android-normalizer-number-parsing branch July 9, 2026 15:18
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.

4 participants