DataURL

Tags
web
Created
Sep 13, 2016 5:58 PM

https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/Data_URIs

数据是 html 可以用 encodeURIComponent 编码

dataurl 算跨域,网页链接 data:text/html,<iframe src="data:text/html,<script>alert(top.location)</script>"> 唯独 Firefox 从遵守规范变成违反规范了

chrome 不允许导航到 dataurl( firefox 58也改了),因为怕钓鱼,但可以下载和直接输入访问

替代方案: open('about:blank').document.write(document.body.outerHTML);

// about:blank 或者 javascript: 算跟当前页面同域

// 导航到 blobURL https://bugs.chromium.org/p/chromium/issues/detail?id=594215

open(URL.createObjectURL(new Blob(["<\meta charset=utf-8>\n" + (self.hasClass("alert_error") ? "<script>onerror = alert<\/script>\n" : "") + "<script>" + self.find("pre").text() + "<\/script>"], {

"type": "text/html"

})))

SuperMade with Super