The output is content
A request for a script or a product description can still return code blocks, links or HTML-like text. That text may be copied from source material or invented. Its origin does not authorize it to modify your page, load resources or execute browser behavior.
What to do next
- 01
Choose the required format
If the feature only needs paragraphs, render paragraphs as text and preserve line breaks safely. Add Markdown features only when they serve a user need, rather than enabling arbitrary HTML for visual convenience.
- 02
Constrain active content
Disable raw HTML, restrict link protocols and avoid automatic embedding of remote images or iframes. If sanitized HTML is unavoidable, use a maintained sanitizer and test the actual parsing and rendering pipeline together.
- 03
Keep content and commands separate
Do not derive privileged application actions from generated tags, hidden attributes or rendered buttons. A user must invoke your real controls, and the backend must validate the resulting operation independently of the displayed text.
A concrete example
Illustrative example: a generated script includes a literal script tag as part of dialogue. The preview displays those characters; it does not execute them. A Markdown link with an unsafe protocol is rejected before it becomes clickable.
Before you call it ready
- Script tags are displayed or removed safely.
- Unsafe link protocols are rejected.
- Generated buttons cannot invoke backend actions.
A locally executed, reproducible check
React server rendering escapes a text child that contains markup syntax.
We executed this exact synthetic fixture on November 16, 2026 with Node v24.16.0 and React 19.2.6. It ran locally with no network requests, account data or model generation. The recorded output below is an observation from that environment, not a platform benchmark. Copy the code into a separate CommonJS file to repeat it with the stated dependencies in a suitable local Node environment; compare the mechanism and check your runtime version.
const React=require('react');
const {renderToStaticMarkup}=require('react-dom/server');
const raw='<img src=x onerror="example()">';
console.log(renderToStaticMarkup(React.createElement('p',null,raw)));
Recorded output and interpretation
No browser executes the string. This checks a React text child under the recorded version, not dangerous HTML insertion, Markdown plugins, URL props or sanitization. Passing generated content to dangerouslySetInnerHTML or a later HTML parser creates a separate boundary that this result does not validate.
A matching local output establishes only the illustrated library or database behavior under these inputs. It does not certify a production integration. Preserve the approved action, authorization boundaries and current AISwapLab request contract when applying the idea.
<p><img src=x onerror="example()"></p>
When to stop or choose another method
Stop rendering generated text through raw HTML APIs until the complete rendering path has a verified restriction and sanitization policy.
