2016-06-13 15 views
2

Ich habe die CSP (Content-Sicherheitsrichtlinie) Plugin-Typen-Richtlinie auf White-List-PDF-Typ wie folgt festgelegt. Beim Versuch, eine PDF-Datei im Iframe mit dem Attribut src zu öffnen, funktioniert es gut mit den Browsern IE 11 und Firefox 47+, aber nicht in Chrome 50+. Was braucht es noch, um es in Chrom arbeiten zu lassen?Öffnen einer PDF eingebettet in Iframe in Chrome mit Inhaltssicherheitsrichtlinie> Plugin-Typen

Content-Security-Policy: default-src 'self'; script-src 'self' 'unsafe-inline' 'unsafe-eval'; object-src 'self'; style-src 'self'; frame-src 'self' plugin-types application/pdf; 

Fehler in Chromkonsole

Resource interpreted as Document but transferred with MIME type application/pdf 
Refused to load 'http://127.0.0.1/module123/open.do?id=10000' (MIME type '') because it violates the following Content Security Policy Directive: 'plugin-types application/pdf'. When enforcing the 'plugin-types' directive, the plugin's media type must be explicitly declared with a 'type' attribute on the containing element (e.g. '<object type="[TYPE GOES HERE]" ...>'). 

Antwort

0

Ich hatte ein ähnliches Problem.

Um das Problem zu beheben, musste ich Blob hinzufügen: zu der Anweisung object-src.

Außerdem musste ich nicht plugin-type angeben.

So wäre es:

Content-Security-Policy: default-src 'self'; script-src 'self' 'unsafe-inline' 'unsafe-eval'; object-src 'self' blob:; style-src 'self'; frame-src 'self';