@@ -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 | } |
@@ -42,45 +42,45 @@ |
||
| 42 | 42 | * @deprecated 17.0.0 |
| 43 | 43 | */ |
| 44 | 44 | class StrictContentSecurityPolicy extends EmptyContentSecurityPolicy { |
| 45 | - /** @var bool Whether inline JS snippets are allowed */ |
|
| 46 | - protected $inlineScriptAllowed = false; |
|
| 47 | - /** @var bool Whether eval in JS scripts is allowed */ |
|
| 48 | - protected $evalScriptAllowed = false; |
|
| 49 | - /** @var array Domains from which scripts can get loaded */ |
|
| 50 | - protected $allowedScriptDomains = [ |
|
| 51 | - '\'self\'', |
|
| 52 | - ]; |
|
| 53 | - /** @var bool Whether inline CSS is allowed */ |
|
| 54 | - protected $inlineStyleAllowed = false; |
|
| 55 | - /** @var array Domains from which CSS can get loaded */ |
|
| 56 | - protected $allowedStyleDomains = [ |
|
| 57 | - '\'self\'', |
|
| 58 | - ]; |
|
| 59 | - /** @var array Domains from which images can get loaded */ |
|
| 60 | - protected $allowedImageDomains = [ |
|
| 61 | - '\'self\'', |
|
| 62 | - 'data:', |
|
| 63 | - 'blob:', |
|
| 64 | - ]; |
|
| 65 | - /** @var array Domains to which connections can be done */ |
|
| 66 | - protected $allowedConnectDomains = [ |
|
| 67 | - '\'self\'', |
|
| 68 | - ]; |
|
| 69 | - /** @var array Domains from which media elements can be loaded */ |
|
| 70 | - protected $allowedMediaDomains = [ |
|
| 71 | - '\'self\'', |
|
| 72 | - ]; |
|
| 73 | - /** @var array Domains from which object elements can be loaded */ |
|
| 74 | - protected $allowedObjectDomains = []; |
|
| 75 | - /** @var array Domains from which iframes can be loaded */ |
|
| 76 | - protected $allowedFrameDomains = []; |
|
| 77 | - /** @var array Domains from which fonts can be loaded */ |
|
| 78 | - protected $allowedFontDomains = [ |
|
| 79 | - '\'self\'', |
|
| 80 | - ]; |
|
| 81 | - /** @var array Domains from which web-workers and nested browsing content can load elements */ |
|
| 82 | - protected $allowedChildSrcDomains = []; |
|
| 45 | + /** @var bool Whether inline JS snippets are allowed */ |
|
| 46 | + protected $inlineScriptAllowed = false; |
|
| 47 | + /** @var bool Whether eval in JS scripts is allowed */ |
|
| 48 | + protected $evalScriptAllowed = false; |
|
| 49 | + /** @var array Domains from which scripts can get loaded */ |
|
| 50 | + protected $allowedScriptDomains = [ |
|
| 51 | + '\'self\'', |
|
| 52 | + ]; |
|
| 53 | + /** @var bool Whether inline CSS is allowed */ |
|
| 54 | + protected $inlineStyleAllowed = false; |
|
| 55 | + /** @var array Domains from which CSS can get loaded */ |
|
| 56 | + protected $allowedStyleDomains = [ |
|
| 57 | + '\'self\'', |
|
| 58 | + ]; |
|
| 59 | + /** @var array Domains from which images can get loaded */ |
|
| 60 | + protected $allowedImageDomains = [ |
|
| 61 | + '\'self\'', |
|
| 62 | + 'data:', |
|
| 63 | + 'blob:', |
|
| 64 | + ]; |
|
| 65 | + /** @var array Domains to which connections can be done */ |
|
| 66 | + protected $allowedConnectDomains = [ |
|
| 67 | + '\'self\'', |
|
| 68 | + ]; |
|
| 69 | + /** @var array Domains from which media elements can be loaded */ |
|
| 70 | + protected $allowedMediaDomains = [ |
|
| 71 | + '\'self\'', |
|
| 72 | + ]; |
|
| 73 | + /** @var array Domains from which object elements can be loaded */ |
|
| 74 | + protected $allowedObjectDomains = []; |
|
| 75 | + /** @var array Domains from which iframes can be loaded */ |
|
| 76 | + protected $allowedFrameDomains = []; |
|
| 77 | + /** @var array Domains from which fonts can be loaded */ |
|
| 78 | + protected $allowedFontDomains = [ |
|
| 79 | + '\'self\'', |
|
| 80 | + ]; |
|
| 81 | + /** @var array Domains from which web-workers and nested browsing content can load elements */ |
|
| 82 | + protected $allowedChildSrcDomains = []; |
|
| 83 | 83 | |
| 84 | - /** @var array Domains which can embed this Nextcloud instance */ |
|
| 85 | - protected $allowedFrameAncestors = []; |
|
| 84 | + /** @var array Domains which can embed this Nextcloud instance */ |
|
| 85 | + protected $allowedFrameAncestors = []; |
|
| 86 | 86 | } |
@@ -31,215 +31,215 @@ |
||
| 31 | 31 | * @package OC\Security\CSP |
| 32 | 32 | */ |
| 33 | 33 | class ContentSecurityPolicy extends \OCP\AppFramework\Http\ContentSecurityPolicy { |
| 34 | - /** |
|
| 35 | - * @return boolean |
|
| 36 | - */ |
|
| 37 | - public function isInlineScriptAllowed(): bool { |
|
| 38 | - return $this->inlineScriptAllowed; |
|
| 39 | - } |
|
| 40 | - |
|
| 41 | - /** |
|
| 42 | - * @param boolean $inlineScriptAllowed |
|
| 43 | - */ |
|
| 44 | - public function setInlineScriptAllowed(bool $inlineScriptAllowed) { |
|
| 45 | - $this->inlineScriptAllowed = $inlineScriptAllowed; |
|
| 46 | - } |
|
| 47 | - |
|
| 48 | - /** |
|
| 49 | - * @return boolean |
|
| 50 | - */ |
|
| 51 | - public function isEvalScriptAllowed(): bool { |
|
| 52 | - return $this->evalScriptAllowed; |
|
| 53 | - } |
|
| 54 | - |
|
| 55 | - /** |
|
| 56 | - * @param boolean $evalScriptAllowed |
|
| 57 | - * |
|
| 58 | - * @deprecated 17.0.0 Unsafe eval should not be used anymore. |
|
| 59 | - */ |
|
| 60 | - public function setEvalScriptAllowed(bool $evalScriptAllowed) { |
|
| 61 | - $this->evalScriptAllowed = $evalScriptAllowed; |
|
| 62 | - } |
|
| 63 | - |
|
| 64 | - /** |
|
| 65 | - * @return array |
|
| 66 | - */ |
|
| 67 | - public function getAllowedScriptDomains(): array { |
|
| 68 | - return $this->allowedScriptDomains; |
|
| 69 | - } |
|
| 70 | - |
|
| 71 | - /** |
|
| 72 | - * @param array $allowedScriptDomains |
|
| 73 | - */ |
|
| 74 | - public function setAllowedScriptDomains(array $allowedScriptDomains) { |
|
| 75 | - $this->allowedScriptDomains = $allowedScriptDomains; |
|
| 76 | - } |
|
| 77 | - |
|
| 78 | - /** |
|
| 79 | - * @return boolean |
|
| 80 | - */ |
|
| 81 | - public function isInlineStyleAllowed(): bool { |
|
| 82 | - return $this->inlineStyleAllowed; |
|
| 83 | - } |
|
| 84 | - |
|
| 85 | - /** |
|
| 86 | - * @param boolean $inlineStyleAllowed |
|
| 87 | - */ |
|
| 88 | - public function setInlineStyleAllowed(bool $inlineStyleAllowed) { |
|
| 89 | - $this->inlineStyleAllowed = $inlineStyleAllowed; |
|
| 90 | - } |
|
| 91 | - |
|
| 92 | - /** |
|
| 93 | - * @return array |
|
| 94 | - */ |
|
| 95 | - public function getAllowedStyleDomains(): array { |
|
| 96 | - return $this->allowedStyleDomains; |
|
| 97 | - } |
|
| 98 | - |
|
| 99 | - /** |
|
| 100 | - * @param array $allowedStyleDomains |
|
| 101 | - */ |
|
| 102 | - public function setAllowedStyleDomains(array $allowedStyleDomains) { |
|
| 103 | - $this->allowedStyleDomains = $allowedStyleDomains; |
|
| 104 | - } |
|
| 105 | - |
|
| 106 | - /** |
|
| 107 | - * @return array |
|
| 108 | - */ |
|
| 109 | - public function getAllowedImageDomains(): array { |
|
| 110 | - return $this->allowedImageDomains; |
|
| 111 | - } |
|
| 112 | - |
|
| 113 | - /** |
|
| 114 | - * @param array $allowedImageDomains |
|
| 115 | - */ |
|
| 116 | - public function setAllowedImageDomains(array $allowedImageDomains) { |
|
| 117 | - $this->allowedImageDomains = $allowedImageDomains; |
|
| 118 | - } |
|
| 119 | - |
|
| 120 | - /** |
|
| 121 | - * @return array |
|
| 122 | - */ |
|
| 123 | - public function getAllowedConnectDomains(): array { |
|
| 124 | - return $this->allowedConnectDomains; |
|
| 125 | - } |
|
| 126 | - |
|
| 127 | - /** |
|
| 128 | - * @param array $allowedConnectDomains |
|
| 129 | - */ |
|
| 130 | - public function setAllowedConnectDomains(array $allowedConnectDomains) { |
|
| 131 | - $this->allowedConnectDomains = $allowedConnectDomains; |
|
| 132 | - } |
|
| 133 | - |
|
| 134 | - /** |
|
| 135 | - * @return array |
|
| 136 | - */ |
|
| 137 | - public function getAllowedMediaDomains(): array { |
|
| 138 | - return $this->allowedMediaDomains; |
|
| 139 | - } |
|
| 140 | - |
|
| 141 | - /** |
|
| 142 | - * @param array $allowedMediaDomains |
|
| 143 | - */ |
|
| 144 | - public function setAllowedMediaDomains(array $allowedMediaDomains) { |
|
| 145 | - $this->allowedMediaDomains = $allowedMediaDomains; |
|
| 146 | - } |
|
| 147 | - |
|
| 148 | - /** |
|
| 149 | - * @return array |
|
| 150 | - */ |
|
| 151 | - public function getAllowedObjectDomains(): array { |
|
| 152 | - return $this->allowedObjectDomains; |
|
| 153 | - } |
|
| 154 | - |
|
| 155 | - /** |
|
| 156 | - * @param array $allowedObjectDomains |
|
| 157 | - */ |
|
| 158 | - public function setAllowedObjectDomains(array $allowedObjectDomains) { |
|
| 159 | - $this->allowedObjectDomains = $allowedObjectDomains; |
|
| 160 | - } |
|
| 161 | - |
|
| 162 | - /** |
|
| 163 | - * @return array |
|
| 164 | - */ |
|
| 165 | - public function getAllowedFrameDomains(): array { |
|
| 166 | - return $this->allowedFrameDomains; |
|
| 167 | - } |
|
| 168 | - |
|
| 169 | - /** |
|
| 170 | - * @param array $allowedFrameDomains |
|
| 171 | - */ |
|
| 172 | - public function setAllowedFrameDomains(array $allowedFrameDomains) { |
|
| 173 | - $this->allowedFrameDomains = $allowedFrameDomains; |
|
| 174 | - } |
|
| 175 | - |
|
| 176 | - /** |
|
| 177 | - * @return array |
|
| 178 | - */ |
|
| 179 | - public function getAllowedFontDomains(): array { |
|
| 180 | - return $this->allowedFontDomains; |
|
| 181 | - } |
|
| 182 | - |
|
| 183 | - /** |
|
| 184 | - * @param array $allowedFontDomains |
|
| 185 | - */ |
|
| 186 | - public function setAllowedFontDomains($allowedFontDomains) { |
|
| 187 | - $this->allowedFontDomains = $allowedFontDomains; |
|
| 188 | - } |
|
| 189 | - |
|
| 190 | - /** |
|
| 191 | - * @return array |
|
| 192 | - * @deprecated 15.0.0 use FrameDomains and WorkerSrcDomains |
|
| 193 | - */ |
|
| 194 | - public function getAllowedChildSrcDomains(): array { |
|
| 195 | - return $this->allowedChildSrcDomains; |
|
| 196 | - } |
|
| 197 | - |
|
| 198 | - /** |
|
| 199 | - * @param array $allowedChildSrcDomains |
|
| 200 | - * @deprecated 15.0.0 use FrameDomains and WorkerSrcDomains |
|
| 201 | - */ |
|
| 202 | - public function setAllowedChildSrcDomains($allowedChildSrcDomains) { |
|
| 203 | - $this->allowedChildSrcDomains = $allowedChildSrcDomains; |
|
| 204 | - } |
|
| 205 | - |
|
| 206 | - /** |
|
| 207 | - * @return array |
|
| 208 | - */ |
|
| 209 | - public function getAllowedFrameAncestors(): array { |
|
| 210 | - return $this->allowedFrameAncestors; |
|
| 211 | - } |
|
| 212 | - |
|
| 213 | - /** |
|
| 214 | - * @param array $allowedFrameAncestors |
|
| 215 | - */ |
|
| 216 | - public function setAllowedFrameAncestors($allowedFrameAncestors) { |
|
| 217 | - $this->allowedFrameAncestors = $allowedFrameAncestors; |
|
| 218 | - } |
|
| 219 | - |
|
| 220 | - public function getAllowedWorkerSrcDomains(): array { |
|
| 221 | - return $this->allowedWorkerSrcDomains; |
|
| 222 | - } |
|
| 223 | - |
|
| 224 | - public function setAllowedWorkerSrcDomains(array $allowedWorkerSrcDomains) { |
|
| 225 | - $this->allowedWorkerSrcDomains = $allowedWorkerSrcDomains; |
|
| 226 | - } |
|
| 227 | - |
|
| 228 | - public function getAllowedFormActionDomains(): array { |
|
| 229 | - return $this->allowedFormActionDomains; |
|
| 230 | - } |
|
| 231 | - |
|
| 232 | - public function setAllowedFormActionDomains(array $allowedFormActionDomains): void { |
|
| 233 | - $this->allowedFormActionDomains = $allowedFormActionDomains; |
|
| 234 | - } |
|
| 235 | - |
|
| 236 | - |
|
| 237 | - public function getReportTo(): array { |
|
| 238 | - return $this->reportTo; |
|
| 239 | - } |
|
| 240 | - |
|
| 241 | - public function setReportTo(array $reportTo) { |
|
| 242 | - $this->reportTo = $reportTo; |
|
| 243 | - } |
|
| 34 | + /** |
|
| 35 | + * @return boolean |
|
| 36 | + */ |
|
| 37 | + public function isInlineScriptAllowed(): bool { |
|
| 38 | + return $this->inlineScriptAllowed; |
|
| 39 | + } |
|
| 40 | + |
|
| 41 | + /** |
|
| 42 | + * @param boolean $inlineScriptAllowed |
|
| 43 | + */ |
|
| 44 | + public function setInlineScriptAllowed(bool $inlineScriptAllowed) { |
|
| 45 | + $this->inlineScriptAllowed = $inlineScriptAllowed; |
|
| 46 | + } |
|
| 47 | + |
|
| 48 | + /** |
|
| 49 | + * @return boolean |
|
| 50 | + */ |
|
| 51 | + public function isEvalScriptAllowed(): bool { |
|
| 52 | + return $this->evalScriptAllowed; |
|
| 53 | + } |
|
| 54 | + |
|
| 55 | + /** |
|
| 56 | + * @param boolean $evalScriptAllowed |
|
| 57 | + * |
|
| 58 | + * @deprecated 17.0.0 Unsafe eval should not be used anymore. |
|
| 59 | + */ |
|
| 60 | + public function setEvalScriptAllowed(bool $evalScriptAllowed) { |
|
| 61 | + $this->evalScriptAllowed = $evalScriptAllowed; |
|
| 62 | + } |
|
| 63 | + |
|
| 64 | + /** |
|
| 65 | + * @return array |
|
| 66 | + */ |
|
| 67 | + public function getAllowedScriptDomains(): array { |
|
| 68 | + return $this->allowedScriptDomains; |
|
| 69 | + } |
|
| 70 | + |
|
| 71 | + /** |
|
| 72 | + * @param array $allowedScriptDomains |
|
| 73 | + */ |
|
| 74 | + public function setAllowedScriptDomains(array $allowedScriptDomains) { |
|
| 75 | + $this->allowedScriptDomains = $allowedScriptDomains; |
|
| 76 | + } |
|
| 77 | + |
|
| 78 | + /** |
|
| 79 | + * @return boolean |
|
| 80 | + */ |
|
| 81 | + public function isInlineStyleAllowed(): bool { |
|
| 82 | + return $this->inlineStyleAllowed; |
|
| 83 | + } |
|
| 84 | + |
|
| 85 | + /** |
|
| 86 | + * @param boolean $inlineStyleAllowed |
|
| 87 | + */ |
|
| 88 | + public function setInlineStyleAllowed(bool $inlineStyleAllowed) { |
|
| 89 | + $this->inlineStyleAllowed = $inlineStyleAllowed; |
|
| 90 | + } |
|
| 91 | + |
|
| 92 | + /** |
|
| 93 | + * @return array |
|
| 94 | + */ |
|
| 95 | + public function getAllowedStyleDomains(): array { |
|
| 96 | + return $this->allowedStyleDomains; |
|
| 97 | + } |
|
| 98 | + |
|
| 99 | + /** |
|
| 100 | + * @param array $allowedStyleDomains |
|
| 101 | + */ |
|
| 102 | + public function setAllowedStyleDomains(array $allowedStyleDomains) { |
|
| 103 | + $this->allowedStyleDomains = $allowedStyleDomains; |
|
| 104 | + } |
|
| 105 | + |
|
| 106 | + /** |
|
| 107 | + * @return array |
|
| 108 | + */ |
|
| 109 | + public function getAllowedImageDomains(): array { |
|
| 110 | + return $this->allowedImageDomains; |
|
| 111 | + } |
|
| 112 | + |
|
| 113 | + /** |
|
| 114 | + * @param array $allowedImageDomains |
|
| 115 | + */ |
|
| 116 | + public function setAllowedImageDomains(array $allowedImageDomains) { |
|
| 117 | + $this->allowedImageDomains = $allowedImageDomains; |
|
| 118 | + } |
|
| 119 | + |
|
| 120 | + /** |
|
| 121 | + * @return array |
|
| 122 | + */ |
|
| 123 | + public function getAllowedConnectDomains(): array { |
|
| 124 | + return $this->allowedConnectDomains; |
|
| 125 | + } |
|
| 126 | + |
|
| 127 | + /** |
|
| 128 | + * @param array $allowedConnectDomains |
|
| 129 | + */ |
|
| 130 | + public function setAllowedConnectDomains(array $allowedConnectDomains) { |
|
| 131 | + $this->allowedConnectDomains = $allowedConnectDomains; |
|
| 132 | + } |
|
| 133 | + |
|
| 134 | + /** |
|
| 135 | + * @return array |
|
| 136 | + */ |
|
| 137 | + public function getAllowedMediaDomains(): array { |
|
| 138 | + return $this->allowedMediaDomains; |
|
| 139 | + } |
|
| 140 | + |
|
| 141 | + /** |
|
| 142 | + * @param array $allowedMediaDomains |
|
| 143 | + */ |
|
| 144 | + public function setAllowedMediaDomains(array $allowedMediaDomains) { |
|
| 145 | + $this->allowedMediaDomains = $allowedMediaDomains; |
|
| 146 | + } |
|
| 147 | + |
|
| 148 | + /** |
|
| 149 | + * @return array |
|
| 150 | + */ |
|
| 151 | + public function getAllowedObjectDomains(): array { |
|
| 152 | + return $this->allowedObjectDomains; |
|
| 153 | + } |
|
| 154 | + |
|
| 155 | + /** |
|
| 156 | + * @param array $allowedObjectDomains |
|
| 157 | + */ |
|
| 158 | + public function setAllowedObjectDomains(array $allowedObjectDomains) { |
|
| 159 | + $this->allowedObjectDomains = $allowedObjectDomains; |
|
| 160 | + } |
|
| 161 | + |
|
| 162 | + /** |
|
| 163 | + * @return array |
|
| 164 | + */ |
|
| 165 | + public function getAllowedFrameDomains(): array { |
|
| 166 | + return $this->allowedFrameDomains; |
|
| 167 | + } |
|
| 168 | + |
|
| 169 | + /** |
|
| 170 | + * @param array $allowedFrameDomains |
|
| 171 | + */ |
|
| 172 | + public function setAllowedFrameDomains(array $allowedFrameDomains) { |
|
| 173 | + $this->allowedFrameDomains = $allowedFrameDomains; |
|
| 174 | + } |
|
| 175 | + |
|
| 176 | + /** |
|
| 177 | + * @return array |
|
| 178 | + */ |
|
| 179 | + public function getAllowedFontDomains(): array { |
|
| 180 | + return $this->allowedFontDomains; |
|
| 181 | + } |
|
| 182 | + |
|
| 183 | + /** |
|
| 184 | + * @param array $allowedFontDomains |
|
| 185 | + */ |
|
| 186 | + public function setAllowedFontDomains($allowedFontDomains) { |
|
| 187 | + $this->allowedFontDomains = $allowedFontDomains; |
|
| 188 | + } |
|
| 189 | + |
|
| 190 | + /** |
|
| 191 | + * @return array |
|
| 192 | + * @deprecated 15.0.0 use FrameDomains and WorkerSrcDomains |
|
| 193 | + */ |
|
| 194 | + public function getAllowedChildSrcDomains(): array { |
|
| 195 | + return $this->allowedChildSrcDomains; |
|
| 196 | + } |
|
| 197 | + |
|
| 198 | + /** |
|
| 199 | + * @param array $allowedChildSrcDomains |
|
| 200 | + * @deprecated 15.0.0 use FrameDomains and WorkerSrcDomains |
|
| 201 | + */ |
|
| 202 | + public function setAllowedChildSrcDomains($allowedChildSrcDomains) { |
|
| 203 | + $this->allowedChildSrcDomains = $allowedChildSrcDomains; |
|
| 204 | + } |
|
| 205 | + |
|
| 206 | + /** |
|
| 207 | + * @return array |
|
| 208 | + */ |
|
| 209 | + public function getAllowedFrameAncestors(): array { |
|
| 210 | + return $this->allowedFrameAncestors; |
|
| 211 | + } |
|
| 212 | + |
|
| 213 | + /** |
|
| 214 | + * @param array $allowedFrameAncestors |
|
| 215 | + */ |
|
| 216 | + public function setAllowedFrameAncestors($allowedFrameAncestors) { |
|
| 217 | + $this->allowedFrameAncestors = $allowedFrameAncestors; |
|
| 218 | + } |
|
| 219 | + |
|
| 220 | + public function getAllowedWorkerSrcDomains(): array { |
|
| 221 | + return $this->allowedWorkerSrcDomains; |
|
| 222 | + } |
|
| 223 | + |
|
| 224 | + public function setAllowedWorkerSrcDomains(array $allowedWorkerSrcDomains) { |
|
| 225 | + $this->allowedWorkerSrcDomains = $allowedWorkerSrcDomains; |
|
| 226 | + } |
|
| 227 | + |
|
| 228 | + public function getAllowedFormActionDomains(): array { |
|
| 229 | + return $this->allowedFormActionDomains; |
|
| 230 | + } |
|
| 231 | + |
|
| 232 | + public function setAllowedFormActionDomains(array $allowedFormActionDomains): void { |
|
| 233 | + $this->allowedFormActionDomains = $allowedFormActionDomains; |
|
| 234 | + } |
|
| 235 | + |
|
| 236 | + |
|
| 237 | + public function getReportTo(): array { |
|
| 238 | + return $this->reportTo; |
|
| 239 | + } |
|
| 240 | + |
|
| 241 | + public function setReportTo(array $reportTo) { |
|
| 242 | + $this->reportTo = $reportTo; |
|
| 243 | + } |
|
| 244 | 244 | |
| 245 | 245 | } |
@@ -41,63 +41,63 @@ |
||
| 41 | 41 | * @since 8.1.0 |
| 42 | 42 | */ |
| 43 | 43 | class ContentSecurityPolicy extends EmptyContentSecurityPolicy { |
| 44 | - /** @var bool Whether inline JS snippets are allowed */ |
|
| 45 | - protected $inlineScriptAllowed = false; |
|
| 46 | - /** @var bool Whether eval in JS scripts is allowed */ |
|
| 47 | - protected $evalScriptAllowed = false; |
|
| 48 | - /** @var array Domains from which scripts can get loaded */ |
|
| 49 | - protected $allowedScriptDomains = [ |
|
| 50 | - '\'self\'', |
|
| 51 | - ]; |
|
| 52 | - /** |
|
| 53 | - * @var bool Whether inline CSS is allowed |
|
| 54 | - * TODO: Disallow per default |
|
| 55 | - * @link https://github.com/owncloud/core/issues/13458 |
|
| 56 | - */ |
|
| 57 | - protected $inlineStyleAllowed = true; |
|
| 58 | - /** @var array Domains from which CSS can get loaded */ |
|
| 59 | - protected $allowedStyleDomains = [ |
|
| 60 | - '\'self\'', |
|
| 61 | - ]; |
|
| 62 | - /** @var array Domains from which images can get loaded */ |
|
| 63 | - protected $allowedImageDomains = [ |
|
| 64 | - '\'self\'', |
|
| 65 | - 'data:', |
|
| 66 | - 'blob:', |
|
| 67 | - ]; |
|
| 68 | - /** @var array Domains to which connections can be done */ |
|
| 69 | - protected $allowedConnectDomains = [ |
|
| 70 | - '\'self\'', |
|
| 71 | - ]; |
|
| 72 | - /** @var array Domains from which media elements can be loaded */ |
|
| 73 | - protected $allowedMediaDomains = [ |
|
| 74 | - '\'self\'', |
|
| 75 | - ]; |
|
| 76 | - /** @var array Domains from which object elements can be loaded */ |
|
| 77 | - protected $allowedObjectDomains = []; |
|
| 78 | - /** @var array Domains from which iframes can be loaded */ |
|
| 79 | - protected $allowedFrameDomains = []; |
|
| 80 | - /** @var array Domains from which fonts can be loaded */ |
|
| 81 | - protected $allowedFontDomains = [ |
|
| 82 | - '\'self\'', |
|
| 83 | - 'data:', |
|
| 84 | - ]; |
|
| 85 | - /** @var array Domains from which web-workers and nested browsing content can load elements */ |
|
| 86 | - protected $allowedChildSrcDomains = []; |
|
| 44 | + /** @var bool Whether inline JS snippets are allowed */ |
|
| 45 | + protected $inlineScriptAllowed = false; |
|
| 46 | + /** @var bool Whether eval in JS scripts is allowed */ |
|
| 47 | + protected $evalScriptAllowed = false; |
|
| 48 | + /** @var array Domains from which scripts can get loaded */ |
|
| 49 | + protected $allowedScriptDomains = [ |
|
| 50 | + '\'self\'', |
|
| 51 | + ]; |
|
| 52 | + /** |
|
| 53 | + * @var bool Whether inline CSS is allowed |
|
| 54 | + * TODO: Disallow per default |
|
| 55 | + * @link https://github.com/owncloud/core/issues/13458 |
|
| 56 | + */ |
|
| 57 | + protected $inlineStyleAllowed = true; |
|
| 58 | + /** @var array Domains from which CSS can get loaded */ |
|
| 59 | + protected $allowedStyleDomains = [ |
|
| 60 | + '\'self\'', |
|
| 61 | + ]; |
|
| 62 | + /** @var array Domains from which images can get loaded */ |
|
| 63 | + protected $allowedImageDomains = [ |
|
| 64 | + '\'self\'', |
|
| 65 | + 'data:', |
|
| 66 | + 'blob:', |
|
| 67 | + ]; |
|
| 68 | + /** @var array Domains to which connections can be done */ |
|
| 69 | + protected $allowedConnectDomains = [ |
|
| 70 | + '\'self\'', |
|
| 71 | + ]; |
|
| 72 | + /** @var array Domains from which media elements can be loaded */ |
|
| 73 | + protected $allowedMediaDomains = [ |
|
| 74 | + '\'self\'', |
|
| 75 | + ]; |
|
| 76 | + /** @var array Domains from which object elements can be loaded */ |
|
| 77 | + protected $allowedObjectDomains = []; |
|
| 78 | + /** @var array Domains from which iframes can be loaded */ |
|
| 79 | + protected $allowedFrameDomains = []; |
|
| 80 | + /** @var array Domains from which fonts can be loaded */ |
|
| 81 | + protected $allowedFontDomains = [ |
|
| 82 | + '\'self\'', |
|
| 83 | + 'data:', |
|
| 84 | + ]; |
|
| 85 | + /** @var array Domains from which web-workers and nested browsing content can load elements */ |
|
| 86 | + protected $allowedChildSrcDomains = []; |
|
| 87 | 87 | |
| 88 | - /** @var array Domains which can embed this Nextcloud instance */ |
|
| 89 | - protected $allowedFrameAncestors = [ |
|
| 90 | - '\'self\'', |
|
| 91 | - ]; |
|
| 88 | + /** @var array Domains which can embed this Nextcloud instance */ |
|
| 89 | + protected $allowedFrameAncestors = [ |
|
| 90 | + '\'self\'', |
|
| 91 | + ]; |
|
| 92 | 92 | |
| 93 | - /** @var array Domains from which web-workers can be loaded */ |
|
| 94 | - protected $allowedWorkerSrcDomains = []; |
|
| 93 | + /** @var array Domains from which web-workers can be loaded */ |
|
| 94 | + protected $allowedWorkerSrcDomains = []; |
|
| 95 | 95 | |
| 96 | - /** @var array Domains which can be used as target for forms */ |
|
| 97 | - protected $allowedFormActionDomains = [ |
|
| 98 | - '\'self\'', |
|
| 99 | - ]; |
|
| 96 | + /** @var array Domains which can be used as target for forms */ |
|
| 97 | + protected $allowedFormActionDomains = [ |
|
| 98 | + '\'self\'', |
|
| 99 | + ]; |
|
| 100 | 100 | |
| 101 | - /** @var array Locations to report violations to */ |
|
| 102 | - protected $reportTo = []; |
|
| 101 | + /** @var array Locations to report violations to */ |
|
| 102 | + protected $reportTo = []; |
|
| 103 | 103 | } |
@@ -31,50 +31,50 @@ |
||
| 31 | 31 | */ |
| 32 | 32 | interface IRoom { |
| 33 | 33 | |
| 34 | - /** |
|
| 35 | - * Get a unique ID for the room |
|
| 36 | - * |
|
| 37 | - * This id has to be unique within the backend |
|
| 38 | - * |
|
| 39 | - * @return string |
|
| 40 | - * @since 14.0.0 |
|
| 41 | - */ |
|
| 42 | - public function getId():string; |
|
| 34 | + /** |
|
| 35 | + * Get a unique ID for the room |
|
| 36 | + * |
|
| 37 | + * This id has to be unique within the backend |
|
| 38 | + * |
|
| 39 | + * @return string |
|
| 40 | + * @since 14.0.0 |
|
| 41 | + */ |
|
| 42 | + public function getId():string; |
|
| 43 | 43 | |
| 44 | - /** |
|
| 45 | - * Get the display name for the room |
|
| 46 | - * |
|
| 47 | - * @return string |
|
| 48 | - * @since 14.0.0 |
|
| 49 | - */ |
|
| 50 | - public function getDisplayName():string; |
|
| 44 | + /** |
|
| 45 | + * Get the display name for the room |
|
| 46 | + * |
|
| 47 | + * @return string |
|
| 48 | + * @since 14.0.0 |
|
| 49 | + */ |
|
| 50 | + public function getDisplayName():string; |
|
| 51 | 51 | |
| 52 | - /** |
|
| 53 | - * Get a list of groupIds that are allowed to access this room |
|
| 54 | - * |
|
| 55 | - * If an empty array is returned, no group restrictions are |
|
| 56 | - * applied. |
|
| 57 | - * |
|
| 58 | - * @return string[] |
|
| 59 | - * @since 14.0.0 |
|
| 60 | - */ |
|
| 61 | - public function getGroupRestrictions():array; |
|
| 52 | + /** |
|
| 53 | + * Get a list of groupIds that are allowed to access this room |
|
| 54 | + * |
|
| 55 | + * If an empty array is returned, no group restrictions are |
|
| 56 | + * applied. |
|
| 57 | + * |
|
| 58 | + * @return string[] |
|
| 59 | + * @since 14.0.0 |
|
| 60 | + */ |
|
| 61 | + public function getGroupRestrictions():array; |
|
| 62 | 62 | |
| 63 | - /** |
|
| 64 | - * Get the email-address for the room |
|
| 65 | - * |
|
| 66 | - * The email-address has to be globally unique |
|
| 67 | - * |
|
| 68 | - * @return string |
|
| 69 | - * @since 14.0.0 |
|
| 70 | - */ |
|
| 71 | - public function getEMail():string; |
|
| 63 | + /** |
|
| 64 | + * Get the email-address for the room |
|
| 65 | + * |
|
| 66 | + * The email-address has to be globally unique |
|
| 67 | + * |
|
| 68 | + * @return string |
|
| 69 | + * @since 14.0.0 |
|
| 70 | + */ |
|
| 71 | + public function getEMail():string; |
|
| 72 | 72 | |
| 73 | - /** |
|
| 74 | - * Get corresponding backend object |
|
| 75 | - * |
|
| 76 | - * @return IBackend |
|
| 77 | - * @since 14.0.0 |
|
| 78 | - */ |
|
| 79 | - public function getBackend():IBackend; |
|
| 73 | + /** |
|
| 74 | + * Get corresponding backend object |
|
| 75 | + * |
|
| 76 | + * @return IBackend |
|
| 77 | + * @since 14.0.0 |
|
| 78 | + */ |
|
| 79 | + public function getBackend():IBackend; |
|
| 80 | 80 | } |
@@ -35,84 +35,84 @@ |
||
| 35 | 35 | */ |
| 36 | 36 | interface IResourceMetadata { |
| 37 | 37 | |
| 38 | - /** |
|
| 39 | - * Type of resource |
|
| 40 | - * |
|
| 41 | - * Allowed values for this key include: |
|
| 42 | - * - projector |
|
| 43 | - * - tv |
|
| 44 | - * - vehicle |
|
| 45 | - * - other |
|
| 46 | - * |
|
| 47 | - * @since 17.0.0 |
|
| 48 | - */ |
|
| 49 | - public const RESOURCE_TYPE = '{http://nextcloud.com/ns}resource-type'; |
|
| 38 | + /** |
|
| 39 | + * Type of resource |
|
| 40 | + * |
|
| 41 | + * Allowed values for this key include: |
|
| 42 | + * - projector |
|
| 43 | + * - tv |
|
| 44 | + * - vehicle |
|
| 45 | + * - other |
|
| 46 | + * |
|
| 47 | + * @since 17.0.0 |
|
| 48 | + */ |
|
| 49 | + public const RESOURCE_TYPE = '{http://nextcloud.com/ns}resource-type'; |
|
| 50 | 50 | |
| 51 | - /** |
|
| 52 | - * If resource is of type vehicle, this describes the type of vehicle |
|
| 53 | - * |
|
| 54 | - * Allowed values: |
|
| 55 | - * - bicycle |
|
| 56 | - * - scooter |
|
| 57 | - * - motorbike |
|
| 58 | - * - car |
|
| 59 | - * - plane |
|
| 60 | - * - helicopter |
|
| 61 | - * - other |
|
| 62 | - * |
|
| 63 | - * @since 17.0.0 |
|
| 64 | - */ |
|
| 65 | - public const VEHICLE_TYPE = '{http://nextcloud.com/ns}resource-vehicle-type'; |
|
| 51 | + /** |
|
| 52 | + * If resource is of type vehicle, this describes the type of vehicle |
|
| 53 | + * |
|
| 54 | + * Allowed values: |
|
| 55 | + * - bicycle |
|
| 56 | + * - scooter |
|
| 57 | + * - motorbike |
|
| 58 | + * - car |
|
| 59 | + * - plane |
|
| 60 | + * - helicopter |
|
| 61 | + * - other |
|
| 62 | + * |
|
| 63 | + * @since 17.0.0 |
|
| 64 | + */ |
|
| 65 | + public const VEHICLE_TYPE = '{http://nextcloud.com/ns}resource-vehicle-type'; |
|
| 66 | 66 | |
| 67 | - /** |
|
| 68 | - * Make of the vehicle |
|
| 69 | - * |
|
| 70 | - * @since 17.0.0 |
|
| 71 | - */ |
|
| 72 | - public const VEHICLE_MAKE = '{http://nextcloud.com/ns}resource-vehicle-make'; |
|
| 67 | + /** |
|
| 68 | + * Make of the vehicle |
|
| 69 | + * |
|
| 70 | + * @since 17.0.0 |
|
| 71 | + */ |
|
| 72 | + public const VEHICLE_MAKE = '{http://nextcloud.com/ns}resource-vehicle-make'; |
|
| 73 | 73 | |
| 74 | - /** |
|
| 75 | - * Model of the vehicle |
|
| 76 | - * |
|
| 77 | - * @since 17.0.0 |
|
| 78 | - */ |
|
| 79 | - public const VEHICLE_MODEL = '{http://nextcloud.com/ns}resource-vehicle-model'; |
|
| 74 | + /** |
|
| 75 | + * Model of the vehicle |
|
| 76 | + * |
|
| 77 | + * @since 17.0.0 |
|
| 78 | + */ |
|
| 79 | + public const VEHICLE_MODEL = '{http://nextcloud.com/ns}resource-vehicle-model'; |
|
| 80 | 80 | |
| 81 | - /** |
|
| 82 | - * Whether or not the car is electric |
|
| 83 | - * |
|
| 84 | - * use '1' for electric, '0' for non-electric |
|
| 85 | - * |
|
| 86 | - * @since 17.0.0 |
|
| 87 | - */ |
|
| 88 | - public const VEHICLE_IS_ELECTRIC = '{http://nextcloud.com/ns}resource-vehicle-is-electric'; |
|
| 81 | + /** |
|
| 82 | + * Whether or not the car is electric |
|
| 83 | + * |
|
| 84 | + * use '1' for electric, '0' for non-electric |
|
| 85 | + * |
|
| 86 | + * @since 17.0.0 |
|
| 87 | + */ |
|
| 88 | + public const VEHICLE_IS_ELECTRIC = '{http://nextcloud.com/ns}resource-vehicle-is-electric'; |
|
| 89 | 89 | |
| 90 | - /** |
|
| 91 | - * Range of vehicle with a full tank |
|
| 92 | - * |
|
| 93 | - * @since 17.0.0 |
|
| 94 | - */ |
|
| 95 | - public const VEHICLE_RANGE = '{http://nextcloud.com/ns}resource-vehicle-range'; |
|
| 90 | + /** |
|
| 91 | + * Range of vehicle with a full tank |
|
| 92 | + * |
|
| 93 | + * @since 17.0.0 |
|
| 94 | + */ |
|
| 95 | + public const VEHICLE_RANGE = '{http://nextcloud.com/ns}resource-vehicle-range'; |
|
| 96 | 96 | |
| 97 | - /** |
|
| 98 | - * Seating capacity of the vehicle |
|
| 99 | - * |
|
| 100 | - * @since 17.0.0 |
|
| 101 | - */ |
|
| 102 | - public const VEHICLE_SEATING_CAPACITY = '{http://nextcloud.com/ns}resource-vehicle-seating-capacity'; |
|
| 97 | + /** |
|
| 98 | + * Seating capacity of the vehicle |
|
| 99 | + * |
|
| 100 | + * @since 17.0.0 |
|
| 101 | + */ |
|
| 102 | + public const VEHICLE_SEATING_CAPACITY = '{http://nextcloud.com/ns}resource-vehicle-seating-capacity'; |
|
| 103 | 103 | |
| 104 | - /** |
|
| 105 | - * Contact information about the person who is responsible to administer / maintain this resource |
|
| 106 | - * This key stores a textual description of name and possible ways to contact the person |
|
| 107 | - * |
|
| 108 | - * @since 17.0.0 |
|
| 109 | - */ |
|
| 110 | - public const CONTACT_PERSON = '{http://nextcloud.com/ns}resource-contact-person'; |
|
| 104 | + /** |
|
| 105 | + * Contact information about the person who is responsible to administer / maintain this resource |
|
| 106 | + * This key stores a textual description of name and possible ways to contact the person |
|
| 107 | + * |
|
| 108 | + * @since 17.0.0 |
|
| 109 | + */ |
|
| 110 | + public const CONTACT_PERSON = '{http://nextcloud.com/ns}resource-contact-person'; |
|
| 111 | 111 | |
| 112 | - /** |
|
| 113 | - * Link to the vcard of the contact person |
|
| 114 | - * |
|
| 115 | - * @since 17.0.0 |
|
| 116 | - */ |
|
| 117 | - public const CONTACT_PERSON_VCARD = '{http://nextcloud.com/ns}resource-contact-person-vcard'; |
|
| 112 | + /** |
|
| 113 | + * Link to the vcard of the contact person |
|
| 114 | + * |
|
| 115 | + * @since 17.0.0 |
|
| 116 | + */ |
|
| 117 | + public const CONTACT_PERSON_VCARD = '{http://nextcloud.com/ns}resource-contact-person-vcard'; |
|
| 118 | 118 | } |
@@ -33,33 +33,33 @@ |
||
| 33 | 33 | */ |
| 34 | 34 | interface IMetadataProvider { |
| 35 | 35 | |
| 36 | - /** |
|
| 37 | - * Get a list of all metadata keys available for this room |
|
| 38 | - * |
|
| 39 | - * Room backends are allowed to return custom keys, beyond the ones |
|
| 40 | - * defined in this class. If they do, they should make sure to use their |
|
| 41 | - * own namespace. |
|
| 42 | - * |
|
| 43 | - * @return String[] - A list of available keys |
|
| 44 | - * @since 17.0.0 |
|
| 45 | - */ |
|
| 46 | - public function getAllAvailableMetadataKeys():array; |
|
| 36 | + /** |
|
| 37 | + * Get a list of all metadata keys available for this room |
|
| 38 | + * |
|
| 39 | + * Room backends are allowed to return custom keys, beyond the ones |
|
| 40 | + * defined in this class. If they do, they should make sure to use their |
|
| 41 | + * own namespace. |
|
| 42 | + * |
|
| 43 | + * @return String[] - A list of available keys |
|
| 44 | + * @since 17.0.0 |
|
| 45 | + */ |
|
| 46 | + public function getAllAvailableMetadataKeys():array; |
|
| 47 | 47 | |
| 48 | - /** |
|
| 49 | - * Get whether or not a metadata key is set for this room |
|
| 50 | - * |
|
| 51 | - * @param string $key - The key to check for |
|
| 52 | - * @return bool - Whether or not key is available |
|
| 53 | - * @since 17.0.0 |
|
| 54 | - */ |
|
| 55 | - public function hasMetadataForKey(string $key):bool; |
|
| 48 | + /** |
|
| 49 | + * Get whether or not a metadata key is set for this room |
|
| 50 | + * |
|
| 51 | + * @param string $key - The key to check for |
|
| 52 | + * @return bool - Whether or not key is available |
|
| 53 | + * @since 17.0.0 |
|
| 54 | + */ |
|
| 55 | + public function hasMetadataForKey(string $key):bool; |
|
| 56 | 56 | |
| 57 | - /** |
|
| 58 | - * Get the value for a metadata key |
|
| 59 | - * |
|
| 60 | - * @param string $key - The key to check for |
|
| 61 | - * @return string|null - The value stored for the key, null if no value stored |
|
| 62 | - * @since 17.0.0 |
|
| 63 | - */ |
|
| 64 | - public function getMetadataForKey(string $key):?string; |
|
| 57 | + /** |
|
| 58 | + * Get the value for a metadata key |
|
| 59 | + * |
|
| 60 | + * @param string $key - The key to check for |
|
| 61 | + * @return string|null - The value stored for the key, null if no value stored |
|
| 62 | + * @since 17.0.0 |
|
| 63 | + */ |
|
| 64 | + public function getMetadataForKey(string $key):?string; |
|
| 65 | 65 | } |
@@ -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 | } |
@@ -38,33 +38,33 @@ |
||
| 38 | 38 | |
| 39 | 39 | class FeaturePolicyMiddleware extends Middleware { |
| 40 | 40 | |
| 41 | - /** @var FeaturePolicyManager */ |
|
| 42 | - private $policyManager; |
|
| 41 | + /** @var FeaturePolicyManager */ |
|
| 42 | + private $policyManager; |
|
| 43 | 43 | |
| 44 | - public function __construct(FeaturePolicyManager $policyManager) { |
|
| 45 | - $this->policyManager = $policyManager; |
|
| 46 | - } |
|
| 44 | + public function __construct(FeaturePolicyManager $policyManager) { |
|
| 45 | + $this->policyManager = $policyManager; |
|
| 46 | + } |
|
| 47 | 47 | |
| 48 | - /** |
|
| 49 | - * Performs the default FeaturePolicy modifications that may be injected by other |
|
| 50 | - * applications |
|
| 51 | - * |
|
| 52 | - * @param Controller $controller |
|
| 53 | - * @param string $methodName |
|
| 54 | - * @param Response $response |
|
| 55 | - * @return Response |
|
| 56 | - */ |
|
| 57 | - public function afterController($controller, $methodName, Response $response): Response { |
|
| 58 | - $policy = !is_null($response->getFeaturePolicy()) ? $response->getFeaturePolicy() : new FeaturePolicy(); |
|
| 48 | + /** |
|
| 49 | + * Performs the default FeaturePolicy modifications that may be injected by other |
|
| 50 | + * applications |
|
| 51 | + * |
|
| 52 | + * @param Controller $controller |
|
| 53 | + * @param string $methodName |
|
| 54 | + * @param Response $response |
|
| 55 | + * @return Response |
|
| 56 | + */ |
|
| 57 | + public function afterController($controller, $methodName, Response $response): Response { |
|
| 58 | + $policy = !is_null($response->getFeaturePolicy()) ? $response->getFeaturePolicy() : new FeaturePolicy(); |
|
| 59 | 59 | |
| 60 | - if (get_class($policy) === EmptyFeaturePolicy::class) { |
|
| 61 | - return $response; |
|
| 62 | - } |
|
| 60 | + if (get_class($policy) === EmptyFeaturePolicy::class) { |
|
| 61 | + return $response; |
|
| 62 | + } |
|
| 63 | 63 | |
| 64 | - $defaultPolicy = $this->policyManager->getDefaultPolicy(); |
|
| 65 | - $defaultPolicy = $this->policyManager->mergePolicies($defaultPolicy, $policy); |
|
| 66 | - $response->setFeaturePolicy($defaultPolicy); |
|
| 64 | + $defaultPolicy = $this->policyManager->getDefaultPolicy(); |
|
| 65 | + $defaultPolicy = $this->policyManager->mergePolicies($defaultPolicy, $policy); |
|
| 66 | + $response->setFeaturePolicy($defaultPolicy); |
|
| 67 | 67 | |
| 68 | - return $response; |
|
| 69 | - } |
|
| 68 | + return $response; |
|
| 69 | + } |
|
| 70 | 70 | } |
@@ -60,10 +60,10 @@ |
||
| 60 | 60 | */ |
| 61 | 61 | public function mergePolicies(FeaturePolicy $defaultPolicy, |
| 62 | 62 | EmptyFeaturePolicy $originalPolicy): FeaturePolicy { |
| 63 | - foreach ((object)(array)$originalPolicy as $name => $value) { |
|
| 64 | - $setter = 'set' . ucfirst($name); |
|
| 63 | + foreach ((object) (array) $originalPolicy as $name => $value) { |
|
| 64 | + $setter = 'set'.ucfirst($name); |
|
| 65 | 65 | if (\is_array($value)) { |
| 66 | - $getter = 'get' . ucfirst($name); |
|
| 66 | + $getter = 'get'.ucfirst($name); |
|
| 67 | 67 | $currentValues = \is_array($defaultPolicy->$getter()) ? $defaultPolicy->$getter() : []; |
| 68 | 68 | $defaultPolicy->$setter(\array_values(\array_unique(\array_merge($currentValues, $value)))); |
| 69 | 69 | } elseif (\is_bool($value)) { |
@@ -31,48 +31,48 @@ |
||
| 31 | 31 | use OCP\Security\FeaturePolicy\AddFeaturePolicyEvent; |
| 32 | 32 | |
| 33 | 33 | class FeaturePolicyManager { |
| 34 | - /** @var EmptyFeaturePolicy[] */ |
|
| 35 | - private $policies = []; |
|
| 34 | + /** @var EmptyFeaturePolicy[] */ |
|
| 35 | + private $policies = []; |
|
| 36 | 36 | |
| 37 | - /** @var IEventDispatcher */ |
|
| 38 | - private $dispatcher; |
|
| 37 | + /** @var IEventDispatcher */ |
|
| 38 | + private $dispatcher; |
|
| 39 | 39 | |
| 40 | - public function __construct(IEventDispatcher $dispatcher) { |
|
| 41 | - $this->dispatcher = $dispatcher; |
|
| 42 | - } |
|
| 40 | + public function __construct(IEventDispatcher $dispatcher) { |
|
| 41 | + $this->dispatcher = $dispatcher; |
|
| 42 | + } |
|
| 43 | 43 | |
| 44 | - public function addDefaultPolicy(EmptyFeaturePolicy $policy): void { |
|
| 45 | - $this->policies[] = $policy; |
|
| 46 | - } |
|
| 44 | + public function addDefaultPolicy(EmptyFeaturePolicy $policy): void { |
|
| 45 | + $this->policies[] = $policy; |
|
| 46 | + } |
|
| 47 | 47 | |
| 48 | - public function getDefaultPolicy(): FeaturePolicy { |
|
| 49 | - $event = new AddFeaturePolicyEvent($this); |
|
| 50 | - $this->dispatcher->dispatchTyped($event); |
|
| 48 | + public function getDefaultPolicy(): FeaturePolicy { |
|
| 49 | + $event = new AddFeaturePolicyEvent($this); |
|
| 50 | + $this->dispatcher->dispatchTyped($event); |
|
| 51 | 51 | |
| 52 | - $defaultPolicy = new FeaturePolicy(); |
|
| 53 | - foreach ($this->policies as $policy) { |
|
| 54 | - $defaultPolicy = $this->mergePolicies($defaultPolicy, $policy); |
|
| 55 | - } |
|
| 56 | - return $defaultPolicy; |
|
| 57 | - } |
|
| 52 | + $defaultPolicy = new FeaturePolicy(); |
|
| 53 | + foreach ($this->policies as $policy) { |
|
| 54 | + $defaultPolicy = $this->mergePolicies($defaultPolicy, $policy); |
|
| 55 | + } |
|
| 56 | + return $defaultPolicy; |
|
| 57 | + } |
|
| 58 | 58 | |
| 59 | - /** |
|
| 60 | - * Merges the first given policy with the second one |
|
| 61 | - * |
|
| 62 | - */ |
|
| 63 | - public function mergePolicies(FeaturePolicy $defaultPolicy, |
|
| 64 | - EmptyFeaturePolicy $originalPolicy): FeaturePolicy { |
|
| 65 | - foreach ((object)(array)$originalPolicy as $name => $value) { |
|
| 66 | - $setter = 'set' . ucfirst($name); |
|
| 67 | - if (\is_array($value)) { |
|
| 68 | - $getter = 'get' . ucfirst($name); |
|
| 69 | - $currentValues = \is_array($defaultPolicy->$getter()) ? $defaultPolicy->$getter() : []; |
|
| 70 | - $defaultPolicy->$setter(\array_values(\array_unique(\array_merge($currentValues, $value)))); |
|
| 71 | - } elseif (\is_bool($value)) { |
|
| 72 | - $defaultPolicy->$setter($value); |
|
| 73 | - } |
|
| 74 | - } |
|
| 59 | + /** |
|
| 60 | + * Merges the first given policy with the second one |
|
| 61 | + * |
|
| 62 | + */ |
|
| 63 | + public function mergePolicies(FeaturePolicy $defaultPolicy, |
|
| 64 | + EmptyFeaturePolicy $originalPolicy): FeaturePolicy { |
|
| 65 | + foreach ((object)(array)$originalPolicy as $name => $value) { |
|
| 66 | + $setter = 'set' . ucfirst($name); |
|
| 67 | + if (\is_array($value)) { |
|
| 68 | + $getter = 'get' . ucfirst($name); |
|
| 69 | + $currentValues = \is_array($defaultPolicy->$getter()) ? $defaultPolicy->$getter() : []; |
|
| 70 | + $defaultPolicy->$setter(\array_values(\array_unique(\array_merge($currentValues, $value)))); |
|
| 71 | + } elseif (\is_bool($value)) { |
|
| 72 | + $defaultPolicy->$setter($value); |
|
| 73 | + } |
|
| 74 | + } |
|
| 75 | 75 | |
| 76 | - return $defaultPolicy; |
|
| 77 | - } |
|
| 76 | + return $defaultPolicy; |
|
| 77 | + } |
|
| 78 | 78 | } |