@@ -6,5 +6,5 @@ |
||
| 6 | 6 | $baseDir = $vendorDir; |
| 7 | 7 | |
| 8 | 8 | return array( |
| 9 | - 'OCA\\CloudFederationAPI\\' => array($baseDir . '/../lib'), |
|
| 9 | + 'OCA\\CloudFederationAPI\\' => array($baseDir.'/../lib'), |
|
| 10 | 10 | ); |
@@ -370,18 +370,18 @@ discard block |
||
| 370 | 370 | private function findFileWithExtension($class, $ext) |
| 371 | 371 | { |
| 372 | 372 | // PSR-4 lookup |
| 373 | - $logicalPathPsr4 = strtr($class, '\\', DIRECTORY_SEPARATOR) . $ext; |
|
| 373 | + $logicalPathPsr4 = strtr($class, '\\', DIRECTORY_SEPARATOR).$ext; |
|
| 374 | 374 | |
| 375 | 375 | $first = $class[0]; |
| 376 | 376 | if (isset($this->prefixLengthsPsr4[$first])) { |
| 377 | 377 | $subPath = $class; |
| 378 | 378 | while (false !== $lastPos = strrpos($subPath, '\\')) { |
| 379 | 379 | $subPath = substr($subPath, 0, $lastPos); |
| 380 | - $search = $subPath . '\\'; |
|
| 380 | + $search = $subPath.'\\'; |
|
| 381 | 381 | if (isset($this->prefixDirsPsr4[$search])) { |
| 382 | - $pathEnd = DIRECTORY_SEPARATOR . substr($logicalPathPsr4, $lastPos + 1); |
|
| 382 | + $pathEnd = DIRECTORY_SEPARATOR.substr($logicalPathPsr4, $lastPos + 1); |
|
| 383 | 383 | foreach ($this->prefixDirsPsr4[$search] as $dir) { |
| 384 | - if (file_exists($file = $dir . $pathEnd)) { |
|
| 384 | + if (file_exists($file = $dir.$pathEnd)) { |
|
| 385 | 385 | return $file; |
| 386 | 386 | } |
| 387 | 387 | } |
@@ -391,7 +391,7 @@ discard block |
||
| 391 | 391 | |
| 392 | 392 | // PSR-4 fallback dirs |
| 393 | 393 | foreach ($this->fallbackDirsPsr4 as $dir) { |
| 394 | - if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr4)) { |
|
| 394 | + if (file_exists($file = $dir.DIRECTORY_SEPARATOR.$logicalPathPsr4)) { |
|
| 395 | 395 | return $file; |
| 396 | 396 | } |
| 397 | 397 | } |
@@ -403,14 +403,14 @@ discard block |
||
| 403 | 403 | . strtr(substr($logicalPathPsr4, $pos + 1), '_', DIRECTORY_SEPARATOR); |
| 404 | 404 | } else { |
| 405 | 405 | // PEAR-like class name |
| 406 | - $logicalPathPsr0 = strtr($class, '_', DIRECTORY_SEPARATOR) . $ext; |
|
| 406 | + $logicalPathPsr0 = strtr($class, '_', DIRECTORY_SEPARATOR).$ext; |
|
| 407 | 407 | } |
| 408 | 408 | |
| 409 | 409 | if (isset($this->prefixesPsr0[$first])) { |
| 410 | 410 | foreach ($this->prefixesPsr0[$first] as $prefix => $dirs) { |
| 411 | 411 | if (0 === strpos($class, $prefix)) { |
| 412 | 412 | foreach ($dirs as $dir) { |
| 413 | - if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr0)) { |
|
| 413 | + if (file_exists($file = $dir.DIRECTORY_SEPARATOR.$logicalPathPsr0)) { |
|
| 414 | 414 | return $file; |
| 415 | 415 | } |
| 416 | 416 | } |
@@ -420,7 +420,7 @@ discard block |
||
| 420 | 420 | |
| 421 | 421 | // PSR-0 fallback dirs |
| 422 | 422 | foreach ($this->fallbackDirsPsr0 as $dir) { |
| 423 | - if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr0)) { |
|
| 423 | + if (file_exists($file = $dir.DIRECTORY_SEPARATOR.$logicalPathPsr0)) { |
|
| 424 | 424 | return $file; |
| 425 | 425 | } |
| 426 | 426 | } |
@@ -6,5 +6,5 @@ |
||
| 6 | 6 | $baseDir = $vendorDir; |
| 7 | 7 | |
| 8 | 8 | return array( |
| 9 | - 'OCA\\WorkflowEngine\\' => array($baseDir . '/../lib'), |
|
| 9 | + 'OCA\\WorkflowEngine\\' => array($baseDir.'/../lib'), |
|
| 10 | 10 | ); |
@@ -31,23 +31,23 @@ |
||
| 31 | 31 | * @deprecated 17.0.0 listen to the AddContentSecurityPolicyEvent to add a policy |
| 32 | 32 | */ |
| 33 | 33 | interface IContentSecurityPolicyManager { |
| 34 | - /** |
|
| 35 | - * Allows to inject something into the default content policy. This is for |
|
| 36 | - * example useful when you're injecting Javascript code into a view belonging |
|
| 37 | - * to another controller and cannot modify its Content-Security-Policy itself. |
|
| 38 | - * Note that the adjustment is only applied to applications that use AppFramework |
|
| 39 | - * controllers. |
|
| 40 | - * |
|
| 41 | - * To use this from your `app.php` use `\OC::$server->getContentSecurityPolicyManager()->addDefaultPolicy($policy)`, |
|
| 42 | - * $policy has to be of type `\OCP\AppFramework\Http\ContentSecurityPolicy`. |
|
| 43 | - * |
|
| 44 | - * WARNING: Using this API incorrectly may make the instance more insecure. |
|
| 45 | - * Do think twice before adding whitelisting resources. Please do also note |
|
| 46 | - * that it is not possible to use the `disallowXYZ` functions. |
|
| 47 | - * |
|
| 48 | - * @param EmptyContentSecurityPolicy $policy |
|
| 49 | - * @since 9.0.0 |
|
| 50 | - * @deprecated 17.0.0 listen to the AddContentSecurityPolicyEvent to add a policy |
|
| 51 | - */ |
|
| 52 | - public function addDefaultPolicy(EmptyContentSecurityPolicy $policy); |
|
| 34 | + /** |
|
| 35 | + * Allows to inject something into the default content policy. This is for |
|
| 36 | + * example useful when you're injecting Javascript code into a view belonging |
|
| 37 | + * to another controller and cannot modify its Content-Security-Policy itself. |
|
| 38 | + * Note that the adjustment is only applied to applications that use AppFramework |
|
| 39 | + * controllers. |
|
| 40 | + * |
|
| 41 | + * To use this from your `app.php` use `\OC::$server->getContentSecurityPolicyManager()->addDefaultPolicy($policy)`, |
|
| 42 | + * $policy has to be of type `\OCP\AppFramework\Http\ContentSecurityPolicy`. |
|
| 43 | + * |
|
| 44 | + * WARNING: Using this API incorrectly may make the instance more insecure. |
|
| 45 | + * Do think twice before adding whitelisting resources. Please do also note |
|
| 46 | + * that it is not possible to use the `disallowXYZ` functions. |
|
| 47 | + * |
|
| 48 | + * @param EmptyContentSecurityPolicy $policy |
|
| 49 | + * @since 9.0.0 |
|
| 50 | + * @deprecated 17.0.0 listen to the AddContentSecurityPolicyEvent to add a policy |
|
| 51 | + */ |
|
| 52 | + public function addDefaultPolicy(EmptyContentSecurityPolicy $policy); |
|
| 53 | 53 | } |
@@ -31,9 +31,9 @@ |
||
| 31 | 31 | * @since 17.0.0 |
| 32 | 32 | */ |
| 33 | 33 | interface IVersionedPreviewFile { |
| 34 | - /** |
|
| 35 | - * @return string |
|
| 36 | - * @since 17.0.0 |
|
| 37 | - */ |
|
| 38 | - public function getPreviewVersion(): string; |
|
| 34 | + /** |
|
| 35 | + * @return string |
|
| 36 | + * @since 17.0.0 |
|
| 37 | + */ |
|
| 38 | + public function getPreviewVersion(): string; |
|
| 39 | 39 | } |
@@ -32,10 +32,10 @@ |
||
| 32 | 32 | */ |
| 33 | 33 | class UnsupportedLimitOnInitialSyncException extends InsufficientStorage { |
| 34 | 34 | |
| 35 | - /** |
|
| 36 | - * @inheritDoc |
|
| 37 | - */ |
|
| 38 | - public function serialize(Server $server, \DOMElement $errorNode) { |
|
| 39 | - $errorNode->appendChild($errorNode->ownerDocument->createElementNS('DAV:', 'd:number-of-matches-within-limits')); |
|
| 40 | - } |
|
| 35 | + /** |
|
| 36 | + * @inheritDoc |
|
| 37 | + */ |
|
| 38 | + public function serialize(Server $server, \DOMElement $errorNode) { |
|
| 39 | + $errorNode->appendChild($errorNode->ownerDocument->createElementNS('DAV:', 'd:number-of-matches-within-limits')); |
|
| 40 | + } |
|
| 41 | 41 | } |
@@ -61,5 +61,5 @@ |
||
| 61 | 61 | * @return string|null - The value stored for the key, null if no value stored |
| 62 | 62 | * @since 17.0.0 |
| 63 | 63 | */ |
| 64 | - public function getMetadataForKey(string $key):?string; |
|
| 64 | + public function getMetadataForKey(string $key): ?string; |
|
| 65 | 65 | } |
@@ -30,33 +30,33 @@ |
||
| 30 | 30 | * @since 17.0.0 |
| 31 | 31 | */ |
| 32 | 32 | interface IMetadataProvider { |
| 33 | - /** |
|
| 34 | - * Get a list of all metadata keys available for this room |
|
| 35 | - * |
|
| 36 | - * Room backends are allowed to return custom keys, beyond the ones |
|
| 37 | - * defined in this class. If they do, they should make sure to use their |
|
| 38 | - * own namespace. |
|
| 39 | - * |
|
| 40 | - * @return String[] - A list of available keys |
|
| 41 | - * @since 17.0.0 |
|
| 42 | - */ |
|
| 43 | - public function getAllAvailableMetadataKeys():array; |
|
| 33 | + /** |
|
| 34 | + * Get a list of all metadata keys available for this room |
|
| 35 | + * |
|
| 36 | + * Room backends are allowed to return custom keys, beyond the ones |
|
| 37 | + * defined in this class. If they do, they should make sure to use their |
|
| 38 | + * own namespace. |
|
| 39 | + * |
|
| 40 | + * @return String[] - A list of available keys |
|
| 41 | + * @since 17.0.0 |
|
| 42 | + */ |
|
| 43 | + public function getAllAvailableMetadataKeys():array; |
|
| 44 | 44 | |
| 45 | - /** |
|
| 46 | - * Get whether or not a metadata key is set for this room |
|
| 47 | - * |
|
| 48 | - * @param string $key - The key to check for |
|
| 49 | - * @return bool - Whether or not key is available |
|
| 50 | - * @since 17.0.0 |
|
| 51 | - */ |
|
| 52 | - public function hasMetadataForKey(string $key):bool; |
|
| 45 | + /** |
|
| 46 | + * Get whether or not a metadata key is set for this room |
|
| 47 | + * |
|
| 48 | + * @param string $key - The key to check for |
|
| 49 | + * @return bool - Whether or not key is available |
|
| 50 | + * @since 17.0.0 |
|
| 51 | + */ |
|
| 52 | + public function hasMetadataForKey(string $key):bool; |
|
| 53 | 53 | |
| 54 | - /** |
|
| 55 | - * Get the value for a metadata key |
|
| 56 | - * |
|
| 57 | - * @param string $key - The key to check for |
|
| 58 | - * @return string|null - The value stored for the key, null if no value stored |
|
| 59 | - * @since 17.0.0 |
|
| 60 | - */ |
|
| 61 | - public function getMetadataForKey(string $key):?string; |
|
| 54 | + /** |
|
| 55 | + * Get the value for a metadata key |
|
| 56 | + * |
|
| 57 | + * @param string $key - The key to check for |
|
| 58 | + * @return string|null - The value stored for the key, null if no value stored |
|
| 59 | + * @since 17.0.0 |
|
| 60 | + */ |
|
| 61 | + public function getMetadataForKey(string $key):?string; |
|
| 62 | 62 | } |
@@ -139,42 +139,42 @@ |
||
| 139 | 139 | if (empty($this->autoplayDomains)) { |
| 140 | 140 | $policy .= "autoplay 'none';"; |
| 141 | 141 | } else { |
| 142 | - $policy .= 'autoplay ' . implode(' ', $this->autoplayDomains); |
|
| 142 | + $policy .= 'autoplay '.implode(' ', $this->autoplayDomains); |
|
| 143 | 143 | $policy .= ';'; |
| 144 | 144 | } |
| 145 | 145 | |
| 146 | 146 | if (empty($this->cameraDomains)) { |
| 147 | 147 | $policy .= "camera 'none';"; |
| 148 | 148 | } else { |
| 149 | - $policy .= 'camera ' . implode(' ', $this->cameraDomains); |
|
| 149 | + $policy .= 'camera '.implode(' ', $this->cameraDomains); |
|
| 150 | 150 | $policy .= ';'; |
| 151 | 151 | } |
| 152 | 152 | |
| 153 | 153 | if (empty($this->fullscreenDomains)) { |
| 154 | 154 | $policy .= "fullscreen 'none';"; |
| 155 | 155 | } else { |
| 156 | - $policy .= 'fullscreen ' . implode(' ', $this->fullscreenDomains); |
|
| 156 | + $policy .= 'fullscreen '.implode(' ', $this->fullscreenDomains); |
|
| 157 | 157 | $policy .= ';'; |
| 158 | 158 | } |
| 159 | 159 | |
| 160 | 160 | if (empty($this->geolocationDomains)) { |
| 161 | 161 | $policy .= "geolocation 'none';"; |
| 162 | 162 | } else { |
| 163 | - $policy .= 'geolocation ' . implode(' ', $this->geolocationDomains); |
|
| 163 | + $policy .= 'geolocation '.implode(' ', $this->geolocationDomains); |
|
| 164 | 164 | $policy .= ';'; |
| 165 | 165 | } |
| 166 | 166 | |
| 167 | 167 | if (empty($this->microphoneDomains)) { |
| 168 | 168 | $policy .= "microphone 'none';"; |
| 169 | 169 | } else { |
| 170 | - $policy .= 'microphone ' . implode(' ', $this->microphoneDomains); |
|
| 170 | + $policy .= 'microphone '.implode(' ', $this->microphoneDomains); |
|
| 171 | 171 | $policy .= ';'; |
| 172 | 172 | } |
| 173 | 173 | |
| 174 | 174 | if (empty($this->paymentDomains)) { |
| 175 | 175 | $policy .= "payment 'none';"; |
| 176 | 176 | } else { |
| 177 | - $policy .= 'payment ' . implode(' ', $this->paymentDomains); |
|
| 177 | + $policy .= 'payment '.implode(' ', $this->paymentDomains); |
|
| 178 | 178 | $policy .= ';'; |
| 179 | 179 | } |
| 180 | 180 | |
@@ -36,147 +36,147 @@ |
||
| 36 | 36 | * @since 17.0.0 |
| 37 | 37 | */ |
| 38 | 38 | class EmptyFeaturePolicy { |
| 39 | - /** @var string[] of allowed domains to autoplay media */ |
|
| 40 | - protected $autoplayDomains = null; |
|
| 41 | - |
|
| 42 | - /** @var string[] of allowed domains that can access the camera */ |
|
| 43 | - protected $cameraDomains = null; |
|
| 44 | - |
|
| 45 | - /** @var string[] of allowed domains that can use fullscreen */ |
|
| 46 | - protected $fullscreenDomains = null; |
|
| 47 | - |
|
| 48 | - /** @var string[] of allowed domains that can use the geolocation of the device */ |
|
| 49 | - protected $geolocationDomains = null; |
|
| 50 | - |
|
| 51 | - /** @var string[] of allowed domains that can use the microphone */ |
|
| 52 | - protected $microphoneDomains = null; |
|
| 53 | - |
|
| 54 | - /** @var string[] of allowed domains that can use the payment API */ |
|
| 55 | - protected $paymentDomains = null; |
|
| 56 | - |
|
| 57 | - /** |
|
| 58 | - * Allows to use autoplay from a specific domain. Use * to allow from all domains. |
|
| 59 | - * |
|
| 60 | - * @param string $domain Domain to whitelist. Any passed value needs to be properly sanitized. |
|
| 61 | - * @return $this |
|
| 62 | - * @since 17.0.0 |
|
| 63 | - */ |
|
| 64 | - public function addAllowedAutoplayDomain(string $domain): self { |
|
| 65 | - $this->autoplayDomains[] = $domain; |
|
| 66 | - return $this; |
|
| 67 | - } |
|
| 68 | - |
|
| 69 | - /** |
|
| 70 | - * Allows to use the camera on a specific domain. Use * to allow from all domains |
|
| 71 | - * |
|
| 72 | - * @param string $domain Domain to whitelist. Any passed value needs to be properly sanitized. |
|
| 73 | - * @return $this |
|
| 74 | - * @since 17.0.0 |
|
| 75 | - */ |
|
| 76 | - public function addAllowedCameraDomain(string $domain): self { |
|
| 77 | - $this->cameraDomains[] = $domain; |
|
| 78 | - return $this; |
|
| 79 | - } |
|
| 80 | - |
|
| 81 | - /** |
|
| 82 | - * Allows the full screen functionality to be used on a specific domain. Use * to allow from all domains |
|
| 83 | - * |
|
| 84 | - * @param string $domain Domain to whitelist. Any passed value needs to be properly sanitized. |
|
| 85 | - * @return $this |
|
| 86 | - * @since 17.0.0 |
|
| 87 | - */ |
|
| 88 | - public function addAllowedFullScreenDomain(string $domain): self { |
|
| 89 | - $this->fullscreenDomains[] = $domain; |
|
| 90 | - return $this; |
|
| 91 | - } |
|
| 92 | - |
|
| 93 | - /** |
|
| 94 | - * Allows to use the geolocation on a specific domain. Use * to allow from all domains |
|
| 95 | - * |
|
| 96 | - * @param string $domain Domain to whitelist. Any passed value needs to be properly sanitized. |
|
| 97 | - * @return $this |
|
| 98 | - * @since 17.0.0 |
|
| 99 | - */ |
|
| 100 | - public function addAllowedGeoLocationDomain(string $domain): self { |
|
| 101 | - $this->geolocationDomains[] = $domain; |
|
| 102 | - return $this; |
|
| 103 | - } |
|
| 104 | - |
|
| 105 | - /** |
|
| 106 | - * Allows to use the microphone on a specific domain. Use * to allow from all domains |
|
| 107 | - * |
|
| 108 | - * @param string $domain Domain to whitelist. Any passed value needs to be properly sanitized. |
|
| 109 | - * @return $this |
|
| 110 | - * @since 17.0.0 |
|
| 111 | - */ |
|
| 112 | - public function addAllowedMicrophoneDomain(string $domain): self { |
|
| 113 | - $this->microphoneDomains[] = $domain; |
|
| 114 | - return $this; |
|
| 115 | - } |
|
| 116 | - |
|
| 117 | - /** |
|
| 118 | - * Allows to use the payment API on a specific domain. Use * to allow from all domains |
|
| 119 | - * |
|
| 120 | - * @param string $domain Domain to whitelist. Any passed value needs to be properly sanitized. |
|
| 121 | - * @return $this |
|
| 122 | - * @since 17.0.0 |
|
| 123 | - */ |
|
| 124 | - public function addAllowedPaymentDomain(string $domain): self { |
|
| 125 | - $this->paymentDomains[] = $domain; |
|
| 126 | - return $this; |
|
| 127 | - } |
|
| 128 | - |
|
| 129 | - /** |
|
| 130 | - * Get the generated Feature-Policy as a string |
|
| 131 | - * |
|
| 132 | - * @return string |
|
| 133 | - * @since 17.0.0 |
|
| 134 | - */ |
|
| 135 | - public function buildPolicy(): string { |
|
| 136 | - $policy = ''; |
|
| 137 | - |
|
| 138 | - if (empty($this->autoplayDomains)) { |
|
| 139 | - $policy .= "autoplay 'none';"; |
|
| 140 | - } else { |
|
| 141 | - $policy .= 'autoplay ' . implode(' ', $this->autoplayDomains); |
|
| 142 | - $policy .= ';'; |
|
| 143 | - } |
|
| 144 | - |
|
| 145 | - if (empty($this->cameraDomains)) { |
|
| 146 | - $policy .= "camera 'none';"; |
|
| 147 | - } else { |
|
| 148 | - $policy .= 'camera ' . implode(' ', $this->cameraDomains); |
|
| 149 | - $policy .= ';'; |
|
| 150 | - } |
|
| 151 | - |
|
| 152 | - if (empty($this->fullscreenDomains)) { |
|
| 153 | - $policy .= "fullscreen 'none';"; |
|
| 154 | - } else { |
|
| 155 | - $policy .= 'fullscreen ' . implode(' ', $this->fullscreenDomains); |
|
| 156 | - $policy .= ';'; |
|
| 157 | - } |
|
| 158 | - |
|
| 159 | - if (empty($this->geolocationDomains)) { |
|
| 160 | - $policy .= "geolocation 'none';"; |
|
| 161 | - } else { |
|
| 162 | - $policy .= 'geolocation ' . implode(' ', $this->geolocationDomains); |
|
| 163 | - $policy .= ';'; |
|
| 164 | - } |
|
| 165 | - |
|
| 166 | - if (empty($this->microphoneDomains)) { |
|
| 167 | - $policy .= "microphone 'none';"; |
|
| 168 | - } else { |
|
| 169 | - $policy .= 'microphone ' . implode(' ', $this->microphoneDomains); |
|
| 170 | - $policy .= ';'; |
|
| 171 | - } |
|
| 172 | - |
|
| 173 | - if (empty($this->paymentDomains)) { |
|
| 174 | - $policy .= "payment 'none';"; |
|
| 175 | - } else { |
|
| 176 | - $policy .= 'payment ' . implode(' ', $this->paymentDomains); |
|
| 177 | - $policy .= ';'; |
|
| 178 | - } |
|
| 179 | - |
|
| 180 | - return rtrim($policy, ';'); |
|
| 181 | - } |
|
| 39 | + /** @var string[] of allowed domains to autoplay media */ |
|
| 40 | + protected $autoplayDomains = null; |
|
| 41 | + |
|
| 42 | + /** @var string[] of allowed domains that can access the camera */ |
|
| 43 | + protected $cameraDomains = null; |
|
| 44 | + |
|
| 45 | + /** @var string[] of allowed domains that can use fullscreen */ |
|
| 46 | + protected $fullscreenDomains = null; |
|
| 47 | + |
|
| 48 | + /** @var string[] of allowed domains that can use the geolocation of the device */ |
|
| 49 | + protected $geolocationDomains = null; |
|
| 50 | + |
|
| 51 | + /** @var string[] of allowed domains that can use the microphone */ |
|
| 52 | + protected $microphoneDomains = null; |
|
| 53 | + |
|
| 54 | + /** @var string[] of allowed domains that can use the payment API */ |
|
| 55 | + protected $paymentDomains = null; |
|
| 56 | + |
|
| 57 | + /** |
|
| 58 | + * Allows to use autoplay from a specific domain. Use * to allow from all domains. |
|
| 59 | + * |
|
| 60 | + * @param string $domain Domain to whitelist. Any passed value needs to be properly sanitized. |
|
| 61 | + * @return $this |
|
| 62 | + * @since 17.0.0 |
|
| 63 | + */ |
|
| 64 | + public function addAllowedAutoplayDomain(string $domain): self { |
|
| 65 | + $this->autoplayDomains[] = $domain; |
|
| 66 | + return $this; |
|
| 67 | + } |
|
| 68 | + |
|
| 69 | + /** |
|
| 70 | + * Allows to use the camera on a specific domain. Use * to allow from all domains |
|
| 71 | + * |
|
| 72 | + * @param string $domain Domain to whitelist. Any passed value needs to be properly sanitized. |
|
| 73 | + * @return $this |
|
| 74 | + * @since 17.0.0 |
|
| 75 | + */ |
|
| 76 | + public function addAllowedCameraDomain(string $domain): self { |
|
| 77 | + $this->cameraDomains[] = $domain; |
|
| 78 | + return $this; |
|
| 79 | + } |
|
| 80 | + |
|
| 81 | + /** |
|
| 82 | + * Allows the full screen functionality to be used on a specific domain. Use * to allow from all domains |
|
| 83 | + * |
|
| 84 | + * @param string $domain Domain to whitelist. Any passed value needs to be properly sanitized. |
|
| 85 | + * @return $this |
|
| 86 | + * @since 17.0.0 |
|
| 87 | + */ |
|
| 88 | + public function addAllowedFullScreenDomain(string $domain): self { |
|
| 89 | + $this->fullscreenDomains[] = $domain; |
|
| 90 | + return $this; |
|
| 91 | + } |
|
| 92 | + |
|
| 93 | + /** |
|
| 94 | + * Allows to use the geolocation on a specific domain. Use * to allow from all domains |
|
| 95 | + * |
|
| 96 | + * @param string $domain Domain to whitelist. Any passed value needs to be properly sanitized. |
|
| 97 | + * @return $this |
|
| 98 | + * @since 17.0.0 |
|
| 99 | + */ |
|
| 100 | + public function addAllowedGeoLocationDomain(string $domain): self { |
|
| 101 | + $this->geolocationDomains[] = $domain; |
|
| 102 | + return $this; |
|
| 103 | + } |
|
| 104 | + |
|
| 105 | + /** |
|
| 106 | + * Allows to use the microphone on a specific domain. Use * to allow from all domains |
|
| 107 | + * |
|
| 108 | + * @param string $domain Domain to whitelist. Any passed value needs to be properly sanitized. |
|
| 109 | + * @return $this |
|
| 110 | + * @since 17.0.0 |
|
| 111 | + */ |
|
| 112 | + public function addAllowedMicrophoneDomain(string $domain): self { |
|
| 113 | + $this->microphoneDomains[] = $domain; |
|
| 114 | + return $this; |
|
| 115 | + } |
|
| 116 | + |
|
| 117 | + /** |
|
| 118 | + * Allows to use the payment API on a specific domain. Use * to allow from all domains |
|
| 119 | + * |
|
| 120 | + * @param string $domain Domain to whitelist. Any passed value needs to be properly sanitized. |
|
| 121 | + * @return $this |
|
| 122 | + * @since 17.0.0 |
|
| 123 | + */ |
|
| 124 | + public function addAllowedPaymentDomain(string $domain): self { |
|
| 125 | + $this->paymentDomains[] = $domain; |
|
| 126 | + return $this; |
|
| 127 | + } |
|
| 128 | + |
|
| 129 | + /** |
|
| 130 | + * Get the generated Feature-Policy as a string |
|
| 131 | + * |
|
| 132 | + * @return string |
|
| 133 | + * @since 17.0.0 |
|
| 134 | + */ |
|
| 135 | + public function buildPolicy(): string { |
|
| 136 | + $policy = ''; |
|
| 137 | + |
|
| 138 | + if (empty($this->autoplayDomains)) { |
|
| 139 | + $policy .= "autoplay 'none';"; |
|
| 140 | + } else { |
|
| 141 | + $policy .= 'autoplay ' . implode(' ', $this->autoplayDomains); |
|
| 142 | + $policy .= ';'; |
|
| 143 | + } |
|
| 144 | + |
|
| 145 | + if (empty($this->cameraDomains)) { |
|
| 146 | + $policy .= "camera 'none';"; |
|
| 147 | + } else { |
|
| 148 | + $policy .= 'camera ' . implode(' ', $this->cameraDomains); |
|
| 149 | + $policy .= ';'; |
|
| 150 | + } |
|
| 151 | + |
|
| 152 | + if (empty($this->fullscreenDomains)) { |
|
| 153 | + $policy .= "fullscreen 'none';"; |
|
| 154 | + } else { |
|
| 155 | + $policy .= 'fullscreen ' . implode(' ', $this->fullscreenDomains); |
|
| 156 | + $policy .= ';'; |
|
| 157 | + } |
|
| 158 | + |
|
| 159 | + if (empty($this->geolocationDomains)) { |
|
| 160 | + $policy .= "geolocation 'none';"; |
|
| 161 | + } else { |
|
| 162 | + $policy .= 'geolocation ' . implode(' ', $this->geolocationDomains); |
|
| 163 | + $policy .= ';'; |
|
| 164 | + } |
|
| 165 | + |
|
| 166 | + if (empty($this->microphoneDomains)) { |
|
| 167 | + $policy .= "microphone 'none';"; |
|
| 168 | + } else { |
|
| 169 | + $policy .= 'microphone ' . implode(' ', $this->microphoneDomains); |
|
| 170 | + $policy .= ';'; |
|
| 171 | + } |
|
| 172 | + |
|
| 173 | + if (empty($this->paymentDomains)) { |
|
| 174 | + $policy .= "payment 'none';"; |
|
| 175 | + } else { |
|
| 176 | + $policy .= 'payment ' . implode(' ', $this->paymentDomains); |
|
| 177 | + $policy .= ';'; |
|
| 178 | + } |
|
| 179 | + |
|
| 180 | + return rtrim($policy, ';'); |
|
| 181 | + } |
|
| 182 | 182 | } |
@@ -37,23 +37,23 @@ |
||
| 37 | 37 | * @since 17.0.0 |
| 38 | 38 | */ |
| 39 | 39 | class FeaturePolicy extends EmptyFeaturePolicy { |
| 40 | - protected $autoplayDomains = [ |
|
| 41 | - '\'self\'', |
|
| 42 | - ]; |
|
| 40 | + protected $autoplayDomains = [ |
|
| 41 | + '\'self\'', |
|
| 42 | + ]; |
|
| 43 | 43 | |
| 44 | - /** @var string[] of allowed domains that can access the camera */ |
|
| 45 | - protected $cameraDomains = []; |
|
| 44 | + /** @var string[] of allowed domains that can access the camera */ |
|
| 45 | + protected $cameraDomains = []; |
|
| 46 | 46 | |
| 47 | - protected $fullscreenDomains = [ |
|
| 48 | - '\'self\'', |
|
| 49 | - ]; |
|
| 47 | + protected $fullscreenDomains = [ |
|
| 48 | + '\'self\'', |
|
| 49 | + ]; |
|
| 50 | 50 | |
| 51 | - /** @var string[] of allowed domains that can use the geolocation of the device */ |
|
| 52 | - protected $geolocationDomains = []; |
|
| 51 | + /** @var string[] of allowed domains that can use the geolocation of the device */ |
|
| 52 | + protected $geolocationDomains = []; |
|
| 53 | 53 | |
| 54 | - /** @var string[] of allowed domains that can use the microphone */ |
|
| 55 | - protected $microphoneDomains = []; |
|
| 54 | + /** @var string[] of allowed domains that can use the microphone */ |
|
| 55 | + protected $microphoneDomains = []; |
|
| 56 | 56 | |
| 57 | - /** @var string[] of allowed domains that can use the payment API */ |
|
| 58 | - protected $paymentDomains = []; |
|
| 57 | + /** @var string[] of allowed domains that can use the payment API */ |
|
| 58 | + protected $paymentDomains = []; |
|
| 59 | 59 | } |