Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug when using & in rich text #1451

Closed
j-great opened this issue Aug 26, 2019 · 0 comments
Closed

Bug when using & in rich text #1451

j-great opened this issue Aug 26, 2019 · 0 comments

Comments

@j-great
Copy link

j-great commented Aug 26, 2019

When I put ampersand (&) together with html/xml in the message, like this:

<FormattedMessage
   defaultMessage="<b>Hey & you!</b>"
   id="hello"
  />

I get this error:

[React Intl] Error formatting the default message for: "hello"
Error: Malformed XML message <h3 xmlns="http://www.w3.org/1999/xhtml">This page contains the following errors:</h3><div xmlns="http://www.w3.org/1999/xhtml" style="font-family:monospace;font-size:12px">error on line 1 at column 19: xmlParseEntityRef: no name

But when I replace the ampersand for another special character, it works fine.
If I remove the tags:

<FormattedMessage
   defaultMessage="Hey & you!"
   id="hello"
  />

It works fine. This also works:

<FormattedMessage
   defaultMessage="Hey &#38 you!"
   id="hello"
  />

It seems to occur when using ampersand without html-code with xml/html tags.
Any idea how to solve this?

I'm using:
Mac Mojave 10.14
Chrome v. 76
Node v 10.15.3

longlho pushed a commit that referenced this issue Aug 30, 2019
New intl-messageformat has new behavior for rich text formatting.
See
/~https://github.com/formatjs/formatjs/tree/master/packages/intl-messageformat#caveats
for more details
fixes #1451
fixes #1442
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

No branches or pull requests

1 participant