remarkablemark/html-react-parser

Cannot Handle Microsoft Meeting Link

tragicmj opened this issue · 4 comments

Expected Behavior

The microsoft meeting link should be parse without causing any error

Actual Behavior

It doesn't gets parsed instead crashes.

Steps to Reproduce

this is the content I am trying to parse

let content = `________________________________________________________________________________
Microsoft Teams meeting
Join on your computer, mobile app or room device
Click here to join the meetinghttps://teams.microsoft.com/l/meetup-join/19:meeting_MWRmMzdmZWMtZjRmYS00NDA0LTgGMtMDI4YWZiOTUyZTNj@thread.v2/0?context={"Tid":"37c354b2-85b0-47f5-b222-07b48d774ee3","Oid":"e1a984f1-8d10-4b70-9b89-1d52d5b34f67"}
Meeting ID: 375 123 950 776
Passcode: vmibUx
Download Teamshttps://www.microsoft.com/en-us/microsoft-teams/download-app | Join on the webhttps://www.microsoft.com/microsoft-teams/join-a-meeting
Or call in (audio only)
+44 20 3321 5208,,71547807#tel:+4420332158,,715477# United Kingdom, London
Phone Conference ID: 715 458 06#
Find a local numberhttps://dialin.teams.microsoft.com/cef001b8-580b-4d45-a672-91ebd4f6f622?id=71547807 | Reset PINhttps://dialin.teams.microsoft.com/usp/pstnconferencing
[https://fs.nhs.net/adfs/portal/logo/logo.jpg]
If you are planning to use Teams for clinical purposes, it is important to review usage with your local Information Governance and Clinical Safety teams to determine and adhere to best practice around patient data management.
Learn Morehttps://aka.ms/JoinTeamsMeeting | Helphttps://support.nhs.net/ | Meeting optionshttps://teams.microsoft.com/meetingOptions/?organizerId=e1a984f1-8d10-4b70-9b89-1d52d5b34f67&tenantId=37c354b2-85b0-47f5-b222-07b48d774ee3&threadId=19_meeting_MWRmMzdmZWMtZjRmYS00NDA0LTgxMGMtMDI4YWZiOTUyZTNj@thread.v2&messageId=0&language=en-US | Legalhttps://portal.nhs.net/Home/AcceptablePolicy



This message may contain confidential information. If you are not the intended recipient please:
i) inform the sender that you have received the message in error before deleting it; and
ii) do not disclose, copy or distribute information in this e-mail or take any action in relation to its content (to do so is strictly prohibited and may be unlawful).
Thank you for your co-operation.

NHSmail is the secure email, collaboration and directory service available for all NHS staff in England. NHSmail is approved for exchanging patient data and other sensitive information with NHSmail and other accredited email services.

For more information and to find out how you can switch visit Joining NHSmail - NHSmail Supporthttps://support.nhs.net/article-categories/joining-nhsmail/

`

Thanks for opening this issue @tragicmj! Can you provide a reproducible example using CodeSandbox?

@tragicmj The error is coming from trying to parse <tel>, which is an invalid HTML element. My recommendation is to either:

  1. Clean the HTML string and remove invalid HTML elements, or
  2. Use dangerouslySetInnerHTML

See updated CodeSandbox for approach 2

asd-ez commented

The same for me, I used

  1. Clean the HTML string and remove invalid HTML elements
'html_string'.replace(/<tel:(.+?)>/g, "tel:$1")