What exactly "because of errors reported by structured header parser" means in `Permissions-Policy` error message

1.9k views Asked by At

I have a Wordpress-Page where I've set following lines in functions.php:

// Permissions-Policy
header("Features-Policy:  accelerometer 'none' ; ambient-light-sensor 'none' ; autoplay 'none' ; camera 'none' ; encrypted-media 'none' ; fullscreen 'none' ; geolocation 'none' ; gyroscope 'none' ; magnetometer 'none' ; microphone 'none' ; midi 'none' ; payment 'none' ; speaker 'none' ; sync-xhr 'none' ; usb 'none' ; notifications 'none' ; vibrate 'none' ; push 'none' ; vr 'none' ");
header("Permissions-Policy: accelerometer 'none' ; ambient-light-sensor 'none' ; autoplay 'none' ; camera 'none' ; encrypted-media 'none' ; fullscreen 'none' ; geolocation 'none' ; gyroscope 'none' ; magnetometer 'none' ; microphone 'none' ; midi 'none' ; payment 'none' ; speaker 'none' ; sync-xhr 'none' ; usb 'none' ; notifications 'none' ; vibrate 'none' ; push 'none' ; vr 'none' ");

And if I open the Webpage, I see this error in the Console:

Error with Permissions-Policy header: Parse of permissions policy failed because of errors reported by structured header parser.

This are the Headers (in DevConsole, during the page-request):
enter image description here

Can anybody tell me what the issue here, or how to figure out, what kind of error those " errors reported by structured header parser" are?

1

There are 1 answers

0
suther On

I've figured it out.

The Syntax, how to write the header has changed.

Before it was:

header("Permissions-Policy: accelerometer 'none' ; ambient-light-sensor 'none' ; autoplay 'none' ; camera 'none' ; encrypted-media 'none' ; fullscreen 'none' ; geolocation 'none' ; gyroscope 'none' ; magnetometer 'none' ; microphone 'none' ; midi 'none' ; payment 'none' ; speaker 'none' ; sync-xhr 'none' ; usb 'none' ; ");

Now it's:

header("Permissions-Policy: accelerometer=(), autoplay=(), camera=(), encrypted-media=(), geolocation=(), gyroscope=(), magnetometer=(), microphone=(), payment=(), speaker=(), sync-xhr=(), usb=() ");

Read this for detail descriptions about that.