如何防止iframe显示电子邮件以加载图片和其他电子邮件跟踪器? [英] How can I prevent an iframe displaying an email to load images and other email trackers?

查看:129
本文介绍了如何防止iframe显示电子邮件以加载图片和其他电子邮件跟踪器?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们有一个Web管理面板,代理商可以在其中查看与客户的对话。

We have a web admin panel in which the agents can see conversations with customers.

这些对话是通过IMAP连接导入普通电子邮件的结果。我们获取未修改的邮箱文件,并将它们存储在数据库中。然后我们对文件进行后处理,以按从,到,日期等进行索引。

Those conversations are the result of importing normal emails thru an IMAP connection. We grab the "untouched" mailbox files and we store them in a database. Then we post-process the files to index by "from", "to", "date" and so on and so forth.

到目前为止,okey。我们可以查找与客户有关的所有电子邮件,并随意渲染。

Up to here, okey. We can seek all the emails involved with a client and render them at will.

然后,当代理在Web管理面板中寻找客户并将其打开时,完整出现电子邮件对话。然后,我们在 iframe 中显示电子邮件的HTML版本(如果没有html版本,则显示文本版本)。 90%的客户发送HTML。

Then when the agent looks for a customer in the web admin panel and opens it, the full email conversation appears. And we display the HTML version of the email within an iframe (or the text version if the html version is not there). 90% of the customers send HTML.

会发生什么?代理在我们的网站中打开电子邮件后, iframe 会加载并显示完整html。这样就可以下载远程加载(图像,声音,样式,如果可以的话)。如果我们通过将跟踪ID附加到资产中来打开电子邮件,则客户可以跟踪(典型的 http://track.example.com/image.jpg?id=123456789

What happens? Upon the agent opening the email in our web, the iframe loads the "full html" and renders it. This makes "remote loading" (images, sounds, styles if so, and whatever) to be downloaded. This allows customers to "track" if we opened the email by appending tracking id's to the assets (typical http://track.example.com/image.jpg?id=123456789)

我已经尝试了 iframe 没有运气的html标签(它仍会下载图像)。

I've tried the "sandbox" attribute of the iframe html tag with no luck (it still downloads the images).

如何以编程方式告诉 iframe 不要加载任何远程内容,而仅呈现初始HTML而无需任何远程调用?

How can I programmatically tell the iframe to not load ANY remote content, and just render the initial HTML without any remote call?

推荐答案

Mozilla的iframe文档列出了的所有可用属性,位于: https://developer.mozilla.org/zh-CN/docs/Web/HTML/Element/iframe

Mozilla's iframe documentation listing all available attributes for the is here: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/iframe

如果您查看沙盒,则没有图像或其他包含项的特定限制,只有对事物l的限制ike正在运行JavaScript。没有其他属性会限制图像并包含图像。

If you look at "sandbox" there is no restriction specific to image or other includes, just restrictions on things like running JavaScript. There are no other attributes that would restrict images and includes.

要解决图像并包含HTML的问题,您需要先在服务器上过滤HTML

To solve the problem of images and includes in your HTML you will need to filter the HTML either at the server before sending it or in the client after it arrives.

服务器:


  • 之前将其存储到数据库中。

  • 在用于检索HTML并将其返回到iframe的代码中。

客户端:


  • 使用AJAX使用HTML填充iframe,并使用可过滤
    响应的代码。通过这种方法,如果更适合您的布局,也可以使用div代替
    iframe。

  • 如果所有用户都将使用Chrome或Firefox,则可以编写浏览器扩展程序时

这篇关于如何防止iframe显示电子邮件以加载图片和其他电子邮件跟踪器?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆