Reputation: 91
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
Upvotes: 1
Views: 1771
Reputation: 48968
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);
});
Upvotes: 1
Reputation: 3047
Inject $compileProvider
in config block of your angular app and add following line:
$compileProvider.aHrefSanitizationWhitelist(/^\s*(blob):/);
Upvotes: 1