Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

[iOS] Named entity   rendered literally, then saved as  

Aperta
#818 1 commento 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 5 giorni

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
3/5
Tempo stimato
1-2 giorni
Idoneità per principianti
76/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
html, objective-c, react-native
Ambito
frontend, mobile

Direzione di ricerca

Start with ios/extensions/StringExtension.mm and inspect getEscapedCharactersInfoFrom and its unescapeMap; the issue identifies this as the iOS decoding path. Compare its named-reference handling with the existing numeric-reference handling and the suggested entities. Done when the reproduction renders a non-breaking space on iOS and getHTML() or onChangeHtml no longer turns   into  ; check whether the existing iOS tests cover this path.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

bug
Before submitting a new issue
  • I tested using the latest version of the library, as the bug might be already fixed. (1.1.1, the latest release; the code below is unchanged on main @ 0d015a7b1d)
  • I tested using a supported version of react native.
  • I checked for possible duplicate issues, with possible answers. (Related but different: #235 / #258 fixed & < >, and #636 / #638 fixed numeric references.)
Bug summary

On iOS, EnrichedTextInput (and EnrichedText) render the named character reference   as the literal six characters  . The next getHTML() / onChangeHtml then escapes the &, so the stored HTML becomes  . After that, the literal text shows up on every platform, because it is now real text.

  is very common input. The HTML serialization algorithm (WHATWG "escaping a string") writes U+00A0 as  . So HTML produced on the web (innerHTML, this library's web editor, Tiptap/ProseMirror getHTML()) contains it whenever the text has a non-breaking space. Browsers insert one for a trailing or double space typed in a contenteditable. This library's Android serializer (EnrichedParser.withinStyle) also writes runs of spaces as  . So content written on web or Android and then edited on iOS gets corrupted.

Cause: getEscapedCharactersInfoFrom in ios/extensions/StringExtension.mm only maps &, < and >, plus numeric references. Android (TagSoup) and web (DOMParser) decode named references.

Suggested fix: add at least   → U+00A0, " → " and ' → ' to unescapeMap. Ideally, decode the full HTML5 named-reference table.

Workaround we use for now: before passing HTML to the component, rewrite   / " / ' to   / " / ', which iOS already decodes.

Library version

1.1.1

Environment info
react-native 0.86.2
expo 57.0.14 (dev client, new architecture)
react 19.2.3
iOS Simulator 18.6 (iPhone 16 Pro); also seen on a physical iPhone running iOS 26
Steps to reproduce
  1. On iOS, render an EnrichedTextInput with:
    <EnrichedTextInput defaultValue={'<html><p>Hello&nbsp;world</p></html>'} onChangeHtml={(e) => console.log(e.nativeEvent.value)} />
    
  2. Observed: the input shows Hello&nbsp;world. Expected: Hello world, with a non-breaking space.
  3. Type one character. Observed in onChangeHtml: …Hello&amp;nbsp;world…. Expected: U+00A0 (or &nbsp;), not &amp;nbsp;.
  4. The same HTML on Android and web renders correctly.
Reproducible example repository

No standalone repo yet. The steps above use the stock component only, with no app code involved.

Lingua principale
C
Stelle
1.4k
Fork
69
Merge medio
9g 3h
PR unite (30g)
7

Preparare l'ambiente

  • Nessun Dockerfile né file Docker Compose
  • Ha un modello di pull request
  • Nessuna guida per i contributori

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di software-mansion/react-native-enriched-html

Tutte le issue di software-mansion/react-native-enriched-html

Issue simili

Altre issue su C

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.