简体   繁体   English

Escaping HTML 转义字符

[英]Escaping HTML Escape Characters

I'm writing an email, and I want to include some custom HTML formatting like:我正在写一个 email,我想包括一些自定义 HTML 格式,如:

<p>Hello Friend</p><br><br>

If I write the above directly in the email body, the email program will automatically escape out of characters like <, >, and &.如果我直接在 email 主体中编写上述内容,则 email 程序将自动转义出 <、> 和 & 等字符。 resulting in the following:结果如下:

&lt;p&gt;Hello Friend&lt;/p&gt;&lt;br&gt;&lt;br&gt;

Is there a way to avoid or reverse this escaping?有没有办法避免或扭转这个 escaping?

The problem is also occurring with a Mail Merge type software called GovDelivery.名为 GovDelivery 的邮件合并类型软件也会出现此问题。 I want to put HTML inside their "macros" but GovDelivery automatically escapes out of the characters making it impossible to have custom formats per email.我想将 HTML 放在他们的“宏”中,但 GovDelivery 会自动从字符中转义,从而无法为每个 email 提供自定义格式。

The email provider does this to prevent against Cross Site Scripting (XSS) attacks and is most likely intentional behavior. email 提供程序这样做是为了防止跨站点脚本 (XSS)攻击,并且很可能是故意行为。

As a solution, most services that disable this behavior use Markdown .作为解决方案,大多数禁用此行为的服务都使用Markdown That may result in similar behavior to what you want.这可能会导致与您想要的类似的行为。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM