1
votes

I am trying to open a pdf file that i call from the server, i receive the file in the format of an arraybuffer. I tried many ways to open the pdf file in a new tab using $window.open and converting the file to other forms. 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.

Anybody got a clue how to fix this ? Thanks

2
nfokho @user3909194Said Saifi
Please provide the code used to open the pdf in a new tab and the exact error message.georgeawg

2 Answers

1
votes

Inject $compileProvider in config block of your angular app and add following line:

 $compileProvider.aHrefSanitizationWhitelist(/^\s*(blob):/);
1
votes

The default sanitization white lists for AngularJS v1.6 are1:

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.

app.config(function($compileProvider) {
    var hrefWhiteList = /^\s*(https?|ftp|mailto|tel|file|blob):/;
    $compileProvider.aHrefSanitizationWhitelist(hrefWhiteList);
});