编码 special characters for safe insertion into HTML
转义 <, >, &, ", and ' in user-supplied text so it can be placed inside HTML without triggering XSS or breaking markup.
- 1
Five characters 有特殊 meaning 在 HTML: < 和 > delimit tags, & 开始 entities, " 和 ' delimit 属性 values. Leaving 它们 unescaped 在用户内容 allows XSS attacks 和 breaks markup.
- 2 HTML 转义器 →
Paste 文本 containing <, >, &, quotes. tool replaces 它们具有 < > & " ' — 安全为 两者元素内容和 属性 values.
- 3 HTML 实体编码器 →
为完整 Unicode entity 编码 (不仅 five 特殊), use 此 tool 到转换所有 non-ASCII characters 到 numeric entities as well.
- 4 HTML 实体解码器 →
反转 the process: paste entity-encoded text to recover the original characters for display or editing.
常见问题
- 什么是 差集之间 html-escape 和 html-entity-编码?
- html-escape 仅 converts five HTML-special characters (< > & " '). html-entity-编码 converts 所有 non-ASCII characters 到 numeric entities too, producing fully ASCII-safe 输出.
- 是 escaping enough 到 prevent XSS?
- Escaping prevents XSS 当 inserting 文本为 元素内容或 quoted attributes. 它是 不充分为 unquoted attributes, URL attributes (use url-编码), 或脚本/风格 contexts — 那些 need 上下文-特定 handling.