小编Bry*_*yce的帖子

同时沙盒并将 JS/HTML 添加到 iFrame

我正在尝试创建一个内部有 JS 火的 iframe,但无法访问父文档。目标是有一个简单的实现并且不包含任何特殊的库。我发现HTML5 Sandbox属性是一个可行的解决方案;然而,事实证明,同时沙箱 iframe并将JS 放入其中是相当困难的。

我努力了:

  1. 将 JS 添加到 iframe,然后将其从父文档中沙箱化。这不起作用,因为 iframe 中的 JS 在应用 iframe 沙箱之前触发
  2. 创建 iframe 并使用srcdoc属性设置 HTML(例如<iframe sandbox="allow-scripts" srcdoc="<body><script src='sample1.js'></script><script src='sample2.js'></script></body>"></iframe>),根据此处,这在 IE 中不起作用
  3. 创建 iframe 并使用src属性设置 HTML(例如<iframe sandbox="allow-scripts" src="javascript:&quot;<html><body><script src='sample1.js'></script><script src='sample2.js'></script></body></html>&quot;"></iframe这在 Firefox 38.0.5 (Mac OS X Yosemite) 中不起作用,但在 Chrome 43 和 Safari 8.0.4 中起作用......“在 Firefox 中不起作用”意味着它确实会允许sample2.js添加<span></span>到iframe DOM,但它不设置span的innerText;因此,它不能按预期工作。
  4. 最后,我刚刚尝试通过JS动态创建一个iframe。将 iframe 添加到 DOM(没有沙箱属性)后,我向其中写入 HTML,其中包含我想要在 iframe 中沙箱化的脚本。在 iframe 头部,我有一个沙箱脚本。 …

html javascript security iframe sandbox

5
推荐指数
1
解决办法
3746
查看次数

将原始电子邮件(带附件)发送给多个收件人

我目前正在使用Python 2.7并尝试使用Boto SES将带有附件(确切地说是CSV)的原始电子邮件发送到多个地址.我可以发送正常的电子邮件send_email(),但在尝试通过发送给多个人时我一直收到错误send_raw_email().

这是我用逗号分隔的收件人字符串得到的错误:

Error sending email: SESIllegalAddressError: 400 Illegal address
<ErrorResponse xmlns="http://ses.amazonaws.com/doc/2010-12-01/">
  <Error>
    <Type>Sender</Type>
    <Code>InvalidParameterValue</Code>
    <Message>Illegal address</Message>
  </Error>
  <RequestId>[the request ID]</RequestId>
</ErrorResponse>
Run Code Online (Sandbox Code Playgroud)

这是使用此代码:

to_emails = "me@example.com, them@example.com"

# create raw email
msg = MIMEMultipart()
msg['Subject'] = 'Email subject'
msg['From'] = 'me@example.com'
msg['To'] = to_emails

part = MIMEText('Attached is an important CSV')
msg.attach(part)

part = MIMEApplication(open(fname, 'rb').read())
part.add_header('Content-Disposition', 'attachment', filename=fname)
msg.attach(part)
# end create raw email

conn = boto.ses.connect_to_region(
    '[my region]',
    aws_access_key_id=s3_access_key, 
    aws_secret_access_key=s3_secret_key
    )
conn.send_raw_email(msg.as_string(),
    source=msg['From'], …
Run Code Online (Sandbox Code Playgroud)

python email boto amazon-web-services

2
推荐指数
1
解决办法
5223
查看次数