@@ -408,87 +408,87 @@ |
||
| 408 | 408 | $policy .= "base-uri 'none';"; |
| 409 | 409 | $policy .= "manifest-src 'self';"; |
| 410 | 410 | |
| 411 | - if(!empty($this->allowedScriptDomains) || $this->inlineScriptAllowed || $this->evalScriptAllowed) { |
|
| 411 | + if (!empty($this->allowedScriptDomains) || $this->inlineScriptAllowed || $this->evalScriptAllowed) { |
|
| 412 | 412 | $policy .= 'script-src '; |
| 413 | - if(is_string($this->useJsNonce)) { |
|
| 413 | + if (is_string($this->useJsNonce)) { |
|
| 414 | 414 | $policy .= '\'nonce-'.base64_encode($this->useJsNonce).'\''; |
| 415 | 415 | $allowedScriptDomains = array_flip($this->allowedScriptDomains); |
| 416 | 416 | unset($allowedScriptDomains['\'self\'']); |
| 417 | 417 | $this->allowedScriptDomains = array_flip($allowedScriptDomains); |
| 418 | - if(count($allowedScriptDomains) !== 0) { |
|
| 418 | + if (count($allowedScriptDomains) !== 0) { |
|
| 419 | 419 | $policy .= ' '; |
| 420 | 420 | } |
| 421 | 421 | } |
| 422 | - if(is_array($this->allowedScriptDomains)) { |
|
| 422 | + if (is_array($this->allowedScriptDomains)) { |
|
| 423 | 423 | $policy .= implode(' ', $this->allowedScriptDomains); |
| 424 | 424 | } |
| 425 | - if($this->inlineScriptAllowed) { |
|
| 425 | + if ($this->inlineScriptAllowed) { |
|
| 426 | 426 | $policy .= ' \'unsafe-inline\''; |
| 427 | 427 | } |
| 428 | - if($this->evalScriptAllowed) { |
|
| 428 | + if ($this->evalScriptAllowed) { |
|
| 429 | 429 | $policy .= ' \'unsafe-eval\''; |
| 430 | 430 | } |
| 431 | 431 | $policy .= ';'; |
| 432 | 432 | } |
| 433 | 433 | |
| 434 | - if(!empty($this->allowedStyleDomains) || $this->inlineStyleAllowed) { |
|
| 434 | + if (!empty($this->allowedStyleDomains) || $this->inlineStyleAllowed) { |
|
| 435 | 435 | $policy .= 'style-src '; |
| 436 | - if(is_array($this->allowedStyleDomains)) { |
|
| 436 | + if (is_array($this->allowedStyleDomains)) { |
|
| 437 | 437 | $policy .= implode(' ', $this->allowedStyleDomains); |
| 438 | 438 | } |
| 439 | - if($this->inlineStyleAllowed) { |
|
| 439 | + if ($this->inlineStyleAllowed) { |
|
| 440 | 440 | $policy .= ' \'unsafe-inline\''; |
| 441 | 441 | } |
| 442 | 442 | $policy .= ';'; |
| 443 | 443 | } |
| 444 | 444 | |
| 445 | - if(!empty($this->allowedImageDomains)) { |
|
| 446 | - $policy .= 'img-src ' . implode(' ', $this->allowedImageDomains); |
|
| 445 | + if (!empty($this->allowedImageDomains)) { |
|
| 446 | + $policy .= 'img-src '.implode(' ', $this->allowedImageDomains); |
|
| 447 | 447 | $policy .= ';'; |
| 448 | 448 | } |
| 449 | 449 | |
| 450 | - if(!empty($this->allowedFontDomains)) { |
|
| 451 | - $policy .= 'font-src ' . implode(' ', $this->allowedFontDomains); |
|
| 450 | + if (!empty($this->allowedFontDomains)) { |
|
| 451 | + $policy .= 'font-src '.implode(' ', $this->allowedFontDomains); |
|
| 452 | 452 | $policy .= ';'; |
| 453 | 453 | } |
| 454 | 454 | |
| 455 | - if(!empty($this->allowedConnectDomains)) { |
|
| 456 | - $policy .= 'connect-src ' . implode(' ', $this->allowedConnectDomains); |
|
| 455 | + if (!empty($this->allowedConnectDomains)) { |
|
| 456 | + $policy .= 'connect-src '.implode(' ', $this->allowedConnectDomains); |
|
| 457 | 457 | $policy .= ';'; |
| 458 | 458 | } |
| 459 | 459 | |
| 460 | - if(!empty($this->allowedMediaDomains)) { |
|
| 461 | - $policy .= 'media-src ' . implode(' ', $this->allowedMediaDomains); |
|
| 460 | + if (!empty($this->allowedMediaDomains)) { |
|
| 461 | + $policy .= 'media-src '.implode(' ', $this->allowedMediaDomains); |
|
| 462 | 462 | $policy .= ';'; |
| 463 | 463 | } |
| 464 | 464 | |
| 465 | - if(!empty($this->allowedObjectDomains)) { |
|
| 466 | - $policy .= 'object-src ' . implode(' ', $this->allowedObjectDomains); |
|
| 465 | + if (!empty($this->allowedObjectDomains)) { |
|
| 466 | + $policy .= 'object-src '.implode(' ', $this->allowedObjectDomains); |
|
| 467 | 467 | $policy .= ';'; |
| 468 | 468 | } |
| 469 | 469 | |
| 470 | - if(!empty($this->allowedFrameDomains)) { |
|
| 471 | - $policy .= 'frame-src ' . implode(' ', $this->allowedFrameDomains); |
|
| 470 | + if (!empty($this->allowedFrameDomains)) { |
|
| 471 | + $policy .= 'frame-src '.implode(' ', $this->allowedFrameDomains); |
|
| 472 | 472 | $policy .= ';'; |
| 473 | 473 | } |
| 474 | 474 | |
| 475 | - if(!empty($this->allowedChildSrcDomains)) { |
|
| 476 | - $policy .= 'child-src ' . implode(' ', $this->allowedChildSrcDomains); |
|
| 475 | + if (!empty($this->allowedChildSrcDomains)) { |
|
| 476 | + $policy .= 'child-src '.implode(' ', $this->allowedChildSrcDomains); |
|
| 477 | 477 | $policy .= ';'; |
| 478 | 478 | } |
| 479 | 479 | |
| 480 | - if(!empty($this->allowedFrameAncestors)) { |
|
| 481 | - $policy .= 'frame-ancestors ' . implode(' ', $this->allowedFrameAncestors); |
|
| 480 | + if (!empty($this->allowedFrameAncestors)) { |
|
| 481 | + $policy .= 'frame-ancestors '.implode(' ', $this->allowedFrameAncestors); |
|
| 482 | 482 | $policy .= ';'; |
| 483 | 483 | } |
| 484 | 484 | |
| 485 | 485 | if (!empty($this->allowedWorkerSrcDomains)) { |
| 486 | - $policy .= 'worker-src ' . implode(' ', $this->allowedWorkerSrcDomains); |
|
| 486 | + $policy .= 'worker-src '.implode(' ', $this->allowedWorkerSrcDomains); |
|
| 487 | 487 | $policy .= ';'; |
| 488 | 488 | } |
| 489 | 489 | |
| 490 | 490 | if (!empty($this->reportTo)) { |
| 491 | - $policy .= 'report-uri ' . implode(' ', $this->reportTo); |
|
| 491 | + $policy .= 'report-uri '.implode(' ', $this->reportTo); |
|
| 492 | 492 | $policy .= ';'; |
| 493 | 493 | } |
| 494 | 494 | |