Display incoming SMS content as untrusted text, rather than interpreting it as webpage markup. A private account or a familiar sender label does not make content safe to insert directly into HTML.
Preserve the text while controlling its destination
A message can legitimately contain angle brackets, quotation marks or an ampersand. The interface should show those characters faithfully rather than treating them as page structure. For ordinary message display, a text-only destination avoids the need to interpret the body as markup.
OWASP’s XSS prevention guidance explains why output handling depends on context. HTML text, an attribute, a URL and a script are parsed differently. A single replacement rule applied at ingestion is not a universal defence for every later use. Developers should follow the framework’s documented safe rendering pattern at the point of output.

Consider a harmless test message containing ordinary punctuation and a label in brackets. It should remain visible as message content in the list, detail view and search result. The test should not change the page layout or create new controls. Use a controlled fixture rather than asking an unknown sender to supply a suspicious message.
Review more than the main detail panel
| Display surface | What needs checking |
|---|---|
| Inbox row | Preview text remains text when shortened |
| Message detail | The original body is rendered without executing markup |
| Search result | Highlighting does not reintroduce unsafe HTML |
| Notification | The supported notification API receives appropriate data |
A safe detail view can be undermined by a preview component that uses a different rendering method. Search highlighting is another common boundary: adding emphasis around a match must not turn the rest of the received body into trusted markup. Test the assembled result, including the surrounding component, rather than only the raw string.

Links need a separate decision
Automatically making a detected URL clickable is an additional feature, not ordinary text display. The application needs a documented policy for acceptable destinations and schemes, appropriate attribute handling and a clear distinction between the message and the inbox’s own controls. Correct HTML escaping alone does not establish that a destination is trustworthy.
Users should still verify the task through a known official entry point. A link being clickable is evidence of the interface’s formatting, not an endorsement of the sender or destination. Do not add a “verified” appearance merely because the text resembles a brand name.
Keep an unchanged authorised source representation where the application’s retention policy allows it. Display transformations should not silently rewrite the record used for troubleshooting. If a display defect is reported, use a minimal harmless fixture and identify the affected surface. There is no need to circulate active codes or entire private conversations to demonstrate a rendering problem.
After a fix, inspect both appearance and behaviour in the final page. The goal is readable, faithful content inside the existing interface, with no new executable behaviour created by incoming text.
Technical reference: OWASP: cross-site scripting prevention.
