[英]pdf opening unsafe blob in new tab angularjs
I am trying to open a pdf file that i call from the server, i receive the file in the format of an arraybuffer.我正在尝试打开从服务器调用的 pdf 文件,我以数组缓冲区的格式接收文件。 I tried many ways to open the pdf file in a new tab using $window.open and converting the file to other forms.
我尝试了很多方法来使用 $window.open 在新选项卡中打开 pdf 文件并将文件转换为其他形式。 Before you suggest downloading, it works but I want to open it in a new tab and it being safe to view as a popup.
在您建议下载之前,它可以工作,但我想在新选项卡中打开它,并且可以安全地作为弹出窗口查看。
The pdf opens with this url after converting it to a blob: "blob: http://console:8012/3c8b129d-3544-4f7e-a606-cf4b5eb6e1f3 " and my problem is that it is unsafe because it starts with a blob: and chrome marks it as unsafe. pdf 在将其转换为 blob 后打开此 url:“blob: http://console:8012/3c8b129d-3544-4f7e-a606-cf4b5eb6e1f3 ”,我的问题是它不安全,因为它以 blob 开头:和chrome 将其标记为不安全。
Anybody got a clue how to fix this ?有人知道如何解决这个问题吗? Thanks
谢谢
在 angular 应用程序的配置块中注入$compileProvider
并添加以下行:
$compileProvider.aHrefSanitizationWhitelist(/^\s*(blob):/);
The default sanitization white lists for AngularJS v1.6 are 1 : AngularJS v1.6 的默认清理白名单是1 :
var aHrefSanitizationWhitelist = /^\s*(https?|ftp|mailto|tel|file):/,
imgSrcSanitizationWhitelist = /^\s*((https?|ftp|file|blob):|data:image\/)/;
Use the $compileProvider.aHrefSanitizationWhitelist method to add blob
to its white list.使用$compileProvider.aHrefSanitizationWhitelist 方法将
blob
添加到其白名单。
app.config(function($compileProvider) {
var hrefWhiteList = /^\s*(https?|ftp|mailto|tel|file|blob):/;
$compileProvider.aHrefSanitizationWhitelist(hrefWhiteList);
});
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.