Unexpected behavior with strings containing ampersand character &
Decision Table
- [x] My issue does not look like “The HTML attribute 'xxx' is ignored” (unless we claim support for it)
- [x] My issue does not look like “The HTML element
<yyy>is not rendered”
Good Faith Declaration
- [x] I have read the HELP document here: https://git.io/JBi6R
- [x] I have read the CONTRIBUTING document here: https://git.io/JJ0Pg
- [x] I have confirmed that this bug has not been reported yet
Description
I have noticed a strange behaviour that probably originates from the library trying to parse special characters in html (&, &lquote, ....), but failing to do so.
// Fails
<RenderHTML source={{ html: "&" }} />
// Works
<RenderHTML source={{ html: "&" }} />
// Fails
<RenderHTML source={{ html: "& " }} />
// Works
<RenderHTML source={{ html: " &" }} />
```
### React Native Information
```sh
don't know what to provide here
```
### RNRH Version
6.3.4
### Tested Platforms
- [ ] Android
- [x] iOS
- [ ] Web
- [ ] MacOS
- [ ] Windows
### Reproduction Platforms
- [ ] Android
- [x] iOS
- [ ] Web
- [ ] MacOS
- [ ] Windows
### Minimal, Reproducible Example
// Fails <RenderHTML source={{ html: "&" }} />
// Works <RenderHTML source={{ html: "&" }} />
// Fails <RenderHTML source={{ html: "& " }} />
// Works <RenderHTML source={{ html: " &" }} />
### Additional Notes
_No response_
I can confirm that this is also happening on Android with the test cases above. The HTML strings I have to deal with are littered with and •.
This is using Expo 53 / RN 0.79.3 on the new arch.
~~Good news. patching in an update to the htmlparser2 dependency seems to have solved it. I will do some testing in the simulator, emulator, and on devices with htmlparser2 8.0.2 and 10.0.0 and put up a PR if all goes well. For now, here's the patch I'm using:~~
Patching turned into a mess that only worked because I had installed htmlparser2 as my own dependency. I ended up adding an override to my package.json. Note that mine is for pnpm:
"pnpm": {
"overrides": {
"htmlparser2": "8.0.2"
}
}
Ultimately, the issue is that @native-html/transient-render-engine needs to update the dependency on htmlparser2.