@@ -38,50 +38,50 @@ |
||
38 | 38 | * @since 8.1.0 |
39 | 39 | */ |
40 | 40 | class ContentSecurityPolicy extends EmptyContentSecurityPolicy { |
41 | - /** @var bool Whether inline JS snippets are allowed */ |
|
42 | - protected $inlineScriptAllowed = false; |
|
43 | - /** |
|
44 | - * @var bool Whether eval in JS scripts is allowed |
|
45 | - * TODO: Disallow per default |
|
46 | - * @link https://github.com/owncloud/core/issues/11925 |
|
47 | - */ |
|
48 | - protected $evalScriptAllowed = true; |
|
49 | - /** @var array Domains from which scripts can get loaded */ |
|
50 | - protected $allowedScriptDomains = [ |
|
51 | - '\'self\'', |
|
52 | - ]; |
|
53 | - /** |
|
54 | - * @var bool Whether inline CSS is allowed |
|
55 | - * TODO: Disallow per default |
|
56 | - * @link https://github.com/owncloud/core/issues/13458 |
|
57 | - */ |
|
58 | - protected $inlineStyleAllowed = true; |
|
59 | - /** @var array Domains from which CSS can get loaded */ |
|
60 | - protected $allowedStyleDomains = [ |
|
61 | - '\'self\'', |
|
62 | - ]; |
|
63 | - /** @var array Domains from which images can get loaded */ |
|
64 | - protected $allowedImageDomains = [ |
|
65 | - '\'self\'', |
|
66 | - 'data:', |
|
67 | - 'blob:', |
|
68 | - ]; |
|
69 | - /** @var array Domains to which connections can be done */ |
|
70 | - protected $allowedConnectDomains = [ |
|
71 | - '\'self\'', |
|
72 | - ]; |
|
73 | - /** @var array Domains from which media elements can be loaded */ |
|
74 | - protected $allowedMediaDomains = [ |
|
75 | - '\'self\'', |
|
76 | - ]; |
|
77 | - /** @var array Domains from which object elements can be loaded */ |
|
78 | - protected $allowedObjectDomains = []; |
|
79 | - /** @var array Domains from which iframes can be loaded */ |
|
80 | - protected $allowedFrameDomains = []; |
|
81 | - /** @var array Domains from which fonts can be loaded */ |
|
82 | - protected $allowedFontDomains = [ |
|
83 | - '\'self\'', |
|
84 | - ]; |
|
85 | - /** @var array Domains from which web-workers and nested browsing content can load elements */ |
|
86 | - protected $allowedChildSrcDomains = []; |
|
41 | + /** @var bool Whether inline JS snippets are allowed */ |
|
42 | + protected $inlineScriptAllowed = false; |
|
43 | + /** |
|
44 | + * @var bool Whether eval in JS scripts is allowed |
|
45 | + * TODO: Disallow per default |
|
46 | + * @link https://github.com/owncloud/core/issues/11925 |
|
47 | + */ |
|
48 | + protected $evalScriptAllowed = true; |
|
49 | + /** @var array Domains from which scripts can get loaded */ |
|
50 | + protected $allowedScriptDomains = [ |
|
51 | + '\'self\'', |
|
52 | + ]; |
|
53 | + /** |
|
54 | + * @var bool Whether inline CSS is allowed |
|
55 | + * TODO: Disallow per default |
|
56 | + * @link https://github.com/owncloud/core/issues/13458 |
|
57 | + */ |
|
58 | + protected $inlineStyleAllowed = true; |
|
59 | + /** @var array Domains from which CSS can get loaded */ |
|
60 | + protected $allowedStyleDomains = [ |
|
61 | + '\'self\'', |
|
62 | + ]; |
|
63 | + /** @var array Domains from which images can get loaded */ |
|
64 | + protected $allowedImageDomains = [ |
|
65 | + '\'self\'', |
|
66 | + 'data:', |
|
67 | + 'blob:', |
|
68 | + ]; |
|
69 | + /** @var array Domains to which connections can be done */ |
|
70 | + protected $allowedConnectDomains = [ |
|
71 | + '\'self\'', |
|
72 | + ]; |
|
73 | + /** @var array Domains from which media elements can be loaded */ |
|
74 | + protected $allowedMediaDomains = [ |
|
75 | + '\'self\'', |
|
76 | + ]; |
|
77 | + /** @var array Domains from which object elements can be loaded */ |
|
78 | + protected $allowedObjectDomains = []; |
|
79 | + /** @var array Domains from which iframes can be loaded */ |
|
80 | + protected $allowedFrameDomains = []; |
|
81 | + /** @var array Domains from which fonts can be loaded */ |
|
82 | + protected $allowedFontDomains = [ |
|
83 | + '\'self\'', |
|
84 | + ]; |
|
85 | + /** @var array Domains from which web-workers and nested browsing content can load elements */ |
|
86 | + protected $allowedChildSrcDomains = []; |
|
87 | 87 | } |
@@ -36,27 +36,27 @@ |
||
36 | 36 | */ |
37 | 37 | class RedirectResponse extends Response { |
38 | 38 | |
39 | - private $redirectURL; |
|
40 | - |
|
41 | - /** |
|
42 | - * Creates a response that redirects to a url |
|
43 | - * @param string $redirectURL the url to redirect to |
|
44 | - * @since 7.0.0 |
|
45 | - */ |
|
46 | - public function __construct($redirectURL) { |
|
47 | - $this->redirectURL = $redirectURL; |
|
48 | - $this->setStatus(Http::STATUS_SEE_OTHER); |
|
49 | - $this->addHeader('Location', $redirectURL); |
|
50 | - } |
|
51 | - |
|
52 | - |
|
53 | - /** |
|
54 | - * @return string the url to redirect |
|
55 | - * @since 7.0.0 |
|
56 | - */ |
|
57 | - public function getRedirectURL() { |
|
58 | - return $this->redirectURL; |
|
59 | - } |
|
39 | + private $redirectURL; |
|
40 | + |
|
41 | + /** |
|
42 | + * Creates a response that redirects to a url |
|
43 | + * @param string $redirectURL the url to redirect to |
|
44 | + * @since 7.0.0 |
|
45 | + */ |
|
46 | + public function __construct($redirectURL) { |
|
47 | + $this->redirectURL = $redirectURL; |
|
48 | + $this->setStatus(Http::STATUS_SEE_OTHER); |
|
49 | + $this->addHeader('Location', $redirectURL); |
|
50 | + } |
|
51 | + |
|
52 | + |
|
53 | + /** |
|
54 | + * @return string the url to redirect |
|
55 | + * @since 7.0.0 |
|
56 | + */ |
|
57 | + public function getRedirectURL() { |
|
58 | + return $this->redirectURL; |
|
59 | + } |
|
60 | 60 | |
61 | 61 | |
62 | 62 | } |
@@ -32,19 +32,19 @@ |
||
32 | 32 | */ |
33 | 33 | class NotFoundResponse extends Response { |
34 | 34 | |
35 | - /** |
|
36 | - * @since 8.1.0 |
|
37 | - */ |
|
38 | - public function __construct() { |
|
39 | - $this->setStatus(404); |
|
40 | - } |
|
35 | + /** |
|
36 | + * @since 8.1.0 |
|
37 | + */ |
|
38 | + public function __construct() { |
|
39 | + $this->setStatus(404); |
|
40 | + } |
|
41 | 41 | |
42 | - /** |
|
43 | - * @return string |
|
44 | - * @since 8.1.0 |
|
45 | - */ |
|
46 | - public function render() { |
|
47 | - $template = new Template('core', '404', 'guest'); |
|
48 | - return $template->fetchPage(); |
|
49 | - } |
|
42 | + /** |
|
43 | + * @return string |
|
44 | + * @since 8.1.0 |
|
45 | + */ |
|
46 | + public function render() { |
|
47 | + $template = new Template('core', '404', 'guest'); |
|
48 | + return $template->fetchPage(); |
|
49 | + } |
|
50 | 50 | } |
@@ -37,48 +37,48 @@ |
||
37 | 37 | */ |
38 | 38 | class DataResponse extends Response { |
39 | 39 | |
40 | - /** |
|
41 | - * response data |
|
42 | - * @var array|object |
|
43 | - */ |
|
44 | - protected $data; |
|
40 | + /** |
|
41 | + * response data |
|
42 | + * @var array|object |
|
43 | + */ |
|
44 | + protected $data; |
|
45 | 45 | |
46 | 46 | |
47 | - /** |
|
48 | - * @param array|object $data the object or array that should be transformed |
|
49 | - * @param int $statusCode the Http status code, defaults to 200 |
|
50 | - * @param array $headers additional key value based headers |
|
51 | - * @since 8.0.0 |
|
52 | - */ |
|
53 | - public function __construct($data=array(), $statusCode=Http::STATUS_OK, |
|
54 | - array $headers=array()) { |
|
55 | - $this->data = $data; |
|
56 | - $this->setStatus($statusCode); |
|
57 | - $this->setHeaders(array_merge($this->getHeaders(), $headers)); |
|
58 | - } |
|
47 | + /** |
|
48 | + * @param array|object $data the object or array that should be transformed |
|
49 | + * @param int $statusCode the Http status code, defaults to 200 |
|
50 | + * @param array $headers additional key value based headers |
|
51 | + * @since 8.0.0 |
|
52 | + */ |
|
53 | + public function __construct($data=array(), $statusCode=Http::STATUS_OK, |
|
54 | + array $headers=array()) { |
|
55 | + $this->data = $data; |
|
56 | + $this->setStatus($statusCode); |
|
57 | + $this->setHeaders(array_merge($this->getHeaders(), $headers)); |
|
58 | + } |
|
59 | 59 | |
60 | 60 | |
61 | - /** |
|
62 | - * Sets values in the data json array |
|
63 | - * @param array|object $data an array or object which will be transformed |
|
64 | - * @return DataResponse Reference to this object |
|
65 | - * @since 8.0.0 |
|
66 | - */ |
|
67 | - public function setData($data){ |
|
68 | - $this->data = $data; |
|
61 | + /** |
|
62 | + * Sets values in the data json array |
|
63 | + * @param array|object $data an array or object which will be transformed |
|
64 | + * @return DataResponse Reference to this object |
|
65 | + * @since 8.0.0 |
|
66 | + */ |
|
67 | + public function setData($data){ |
|
68 | + $this->data = $data; |
|
69 | 69 | |
70 | - return $this; |
|
71 | - } |
|
70 | + return $this; |
|
71 | + } |
|
72 | 72 | |
73 | 73 | |
74 | - /** |
|
75 | - * Used to get the set parameters |
|
76 | - * @return array the data |
|
77 | - * @since 8.0.0 |
|
78 | - */ |
|
79 | - public function getData(){ |
|
80 | - return $this->data; |
|
81 | - } |
|
74 | + /** |
|
75 | + * Used to get the set parameters |
|
76 | + * @return array the data |
|
77 | + * @since 8.0.0 |
|
78 | + */ |
|
79 | + public function getData(){ |
|
80 | + return $this->data; |
|
81 | + } |
|
82 | 82 | |
83 | 83 | |
84 | 84 | } |
@@ -50,8 +50,8 @@ discard block |
||
50 | 50 | * @param array $headers additional key value based headers |
51 | 51 | * @since 8.0.0 |
52 | 52 | */ |
53 | - public function __construct($data=array(), $statusCode=Http::STATUS_OK, |
|
54 | - array $headers=array()) { |
|
53 | + public function __construct($data = array(), $statusCode = Http::STATUS_OK, |
|
54 | + array $headers = array()) { |
|
55 | 55 | $this->data = $data; |
56 | 56 | $this->setStatus($statusCode); |
57 | 57 | $this->setHeaders(array_merge($this->getHeaders(), $headers)); |
@@ -64,7 +64,7 @@ discard block |
||
64 | 64 | * @return DataResponse Reference to this object |
65 | 65 | * @since 8.0.0 |
66 | 66 | */ |
67 | - public function setData($data){ |
|
67 | + public function setData($data) { |
|
68 | 68 | $this->data = $data; |
69 | 69 | |
70 | 70 | return $this; |
@@ -76,7 +76,7 @@ discard block |
||
76 | 76 | * @return array the data |
77 | 77 | * @since 8.0.0 |
78 | 78 | */ |
79 | - public function getData(){ |
|
79 | + public function getData() { |
|
80 | 80 | return $this->data; |
81 | 81 | } |
82 | 82 |
@@ -37,124 +37,124 @@ |
||
37 | 37 | */ |
38 | 38 | class TemplateResponse extends Response { |
39 | 39 | |
40 | - /** |
|
41 | - * name of the template |
|
42 | - * @var string |
|
43 | - */ |
|
44 | - protected $templateName; |
|
45 | - |
|
46 | - /** |
|
47 | - * parameters |
|
48 | - * @var array |
|
49 | - */ |
|
50 | - protected $params; |
|
51 | - |
|
52 | - /** |
|
53 | - * rendering type (admin, user, blank) |
|
54 | - * @var string |
|
55 | - */ |
|
56 | - protected $renderAs; |
|
57 | - |
|
58 | - /** |
|
59 | - * app name |
|
60 | - * @var string |
|
61 | - */ |
|
62 | - protected $appName; |
|
63 | - |
|
64 | - /** |
|
65 | - * constructor of TemplateResponse |
|
66 | - * @param string $appName the name of the app to load the template from |
|
67 | - * @param string $templateName the name of the template |
|
68 | - * @param array $params an array of parameters which should be passed to the |
|
69 | - * template |
|
70 | - * @param string $renderAs how the page should be rendered, defaults to user |
|
71 | - * @since 6.0.0 - parameters $params and $renderAs were added in 7.0.0 |
|
72 | - */ |
|
73 | - public function __construct($appName, $templateName, array $params=array(), |
|
74 | - $renderAs='user') { |
|
75 | - $this->templateName = $templateName; |
|
76 | - $this->appName = $appName; |
|
77 | - $this->params = $params; |
|
78 | - $this->renderAs = $renderAs; |
|
79 | - } |
|
80 | - |
|
81 | - |
|
82 | - /** |
|
83 | - * Sets template parameters |
|
84 | - * @param array $params an array with key => value structure which sets template |
|
85 | - * variables |
|
86 | - * @return TemplateResponse Reference to this object |
|
87 | - * @since 6.0.0 - return value was added in 7.0.0 |
|
88 | - */ |
|
89 | - public function setParams(array $params){ |
|
90 | - $this->params = $params; |
|
91 | - |
|
92 | - return $this; |
|
93 | - } |
|
94 | - |
|
95 | - |
|
96 | - /** |
|
97 | - * Used for accessing the set parameters |
|
98 | - * @return array the params |
|
99 | - * @since 6.0.0 |
|
100 | - */ |
|
101 | - public function getParams(){ |
|
102 | - return $this->params; |
|
103 | - } |
|
104 | - |
|
105 | - |
|
106 | - /** |
|
107 | - * Used for accessing the name of the set template |
|
108 | - * @return string the name of the used template |
|
109 | - * @since 6.0.0 |
|
110 | - */ |
|
111 | - public function getTemplateName(){ |
|
112 | - return $this->templateName; |
|
113 | - } |
|
114 | - |
|
115 | - |
|
116 | - /** |
|
117 | - * Sets the template page |
|
118 | - * @param string $renderAs admin, user or blank. Admin also prints the admin |
|
119 | - * settings header and footer, user renders the normal |
|
120 | - * normal page including footer and header and blank |
|
121 | - * just renders the plain template |
|
122 | - * @return TemplateResponse Reference to this object |
|
123 | - * @since 6.0.0 - return value was added in 7.0.0 |
|
124 | - */ |
|
125 | - public function renderAs($renderAs){ |
|
126 | - $this->renderAs = $renderAs; |
|
127 | - |
|
128 | - return $this; |
|
129 | - } |
|
130 | - |
|
131 | - |
|
132 | - /** |
|
133 | - * Returns the set renderAs |
|
134 | - * @return string the renderAs value |
|
135 | - * @since 6.0.0 |
|
136 | - */ |
|
137 | - public function getRenderAs(){ |
|
138 | - return $this->renderAs; |
|
139 | - } |
|
140 | - |
|
141 | - |
|
142 | - /** |
|
143 | - * Returns the rendered html |
|
144 | - * @return string the rendered html |
|
145 | - * @since 6.0.0 |
|
146 | - */ |
|
147 | - public function render(){ |
|
148 | - // \OCP\Template needs an empty string instead of 'blank' for an unwrapped response |
|
149 | - $renderAs = $this->renderAs === 'blank' ? '' : $this->renderAs; |
|
150 | - |
|
151 | - $template = new \OCP\Template($this->appName, $this->templateName, $renderAs); |
|
152 | - |
|
153 | - foreach($this->params as $key => $value){ |
|
154 | - $template->assign($key, $value); |
|
155 | - } |
|
156 | - |
|
157 | - return $template->fetchPage(); |
|
158 | - } |
|
40 | + /** |
|
41 | + * name of the template |
|
42 | + * @var string |
|
43 | + */ |
|
44 | + protected $templateName; |
|
45 | + |
|
46 | + /** |
|
47 | + * parameters |
|
48 | + * @var array |
|
49 | + */ |
|
50 | + protected $params; |
|
51 | + |
|
52 | + /** |
|
53 | + * rendering type (admin, user, blank) |
|
54 | + * @var string |
|
55 | + */ |
|
56 | + protected $renderAs; |
|
57 | + |
|
58 | + /** |
|
59 | + * app name |
|
60 | + * @var string |
|
61 | + */ |
|
62 | + protected $appName; |
|
63 | + |
|
64 | + /** |
|
65 | + * constructor of TemplateResponse |
|
66 | + * @param string $appName the name of the app to load the template from |
|
67 | + * @param string $templateName the name of the template |
|
68 | + * @param array $params an array of parameters which should be passed to the |
|
69 | + * template |
|
70 | + * @param string $renderAs how the page should be rendered, defaults to user |
|
71 | + * @since 6.0.0 - parameters $params and $renderAs were added in 7.0.0 |
|
72 | + */ |
|
73 | + public function __construct($appName, $templateName, array $params=array(), |
|
74 | + $renderAs='user') { |
|
75 | + $this->templateName = $templateName; |
|
76 | + $this->appName = $appName; |
|
77 | + $this->params = $params; |
|
78 | + $this->renderAs = $renderAs; |
|
79 | + } |
|
80 | + |
|
81 | + |
|
82 | + /** |
|
83 | + * Sets template parameters |
|
84 | + * @param array $params an array with key => value structure which sets template |
|
85 | + * variables |
|
86 | + * @return TemplateResponse Reference to this object |
|
87 | + * @since 6.0.0 - return value was added in 7.0.0 |
|
88 | + */ |
|
89 | + public function setParams(array $params){ |
|
90 | + $this->params = $params; |
|
91 | + |
|
92 | + return $this; |
|
93 | + } |
|
94 | + |
|
95 | + |
|
96 | + /** |
|
97 | + * Used for accessing the set parameters |
|
98 | + * @return array the params |
|
99 | + * @since 6.0.0 |
|
100 | + */ |
|
101 | + public function getParams(){ |
|
102 | + return $this->params; |
|
103 | + } |
|
104 | + |
|
105 | + |
|
106 | + /** |
|
107 | + * Used for accessing the name of the set template |
|
108 | + * @return string the name of the used template |
|
109 | + * @since 6.0.0 |
|
110 | + */ |
|
111 | + public function getTemplateName(){ |
|
112 | + return $this->templateName; |
|
113 | + } |
|
114 | + |
|
115 | + |
|
116 | + /** |
|
117 | + * Sets the template page |
|
118 | + * @param string $renderAs admin, user or blank. Admin also prints the admin |
|
119 | + * settings header and footer, user renders the normal |
|
120 | + * normal page including footer and header and blank |
|
121 | + * just renders the plain template |
|
122 | + * @return TemplateResponse Reference to this object |
|
123 | + * @since 6.0.0 - return value was added in 7.0.0 |
|
124 | + */ |
|
125 | + public function renderAs($renderAs){ |
|
126 | + $this->renderAs = $renderAs; |
|
127 | + |
|
128 | + return $this; |
|
129 | + } |
|
130 | + |
|
131 | + |
|
132 | + /** |
|
133 | + * Returns the set renderAs |
|
134 | + * @return string the renderAs value |
|
135 | + * @since 6.0.0 |
|
136 | + */ |
|
137 | + public function getRenderAs(){ |
|
138 | + return $this->renderAs; |
|
139 | + } |
|
140 | + |
|
141 | + |
|
142 | + /** |
|
143 | + * Returns the rendered html |
|
144 | + * @return string the rendered html |
|
145 | + * @since 6.0.0 |
|
146 | + */ |
|
147 | + public function render(){ |
|
148 | + // \OCP\Template needs an empty string instead of 'blank' for an unwrapped response |
|
149 | + $renderAs = $this->renderAs === 'blank' ? '' : $this->renderAs; |
|
150 | + |
|
151 | + $template = new \OCP\Template($this->appName, $this->templateName, $renderAs); |
|
152 | + |
|
153 | + foreach($this->params as $key => $value){ |
|
154 | + $template->assign($key, $value); |
|
155 | + } |
|
156 | + |
|
157 | + return $template->fetchPage(); |
|
158 | + } |
|
159 | 159 | |
160 | 160 | } |
@@ -70,8 +70,8 @@ discard block |
||
70 | 70 | * @param string $renderAs how the page should be rendered, defaults to user |
71 | 71 | * @since 6.0.0 - parameters $params and $renderAs were added in 7.0.0 |
72 | 72 | */ |
73 | - public function __construct($appName, $templateName, array $params=array(), |
|
74 | - $renderAs='user') { |
|
73 | + public function __construct($appName, $templateName, array $params = array(), |
|
74 | + $renderAs = 'user') { |
|
75 | 75 | $this->templateName = $templateName; |
76 | 76 | $this->appName = $appName; |
77 | 77 | $this->params = $params; |
@@ -86,7 +86,7 @@ discard block |
||
86 | 86 | * @return TemplateResponse Reference to this object |
87 | 87 | * @since 6.0.0 - return value was added in 7.0.0 |
88 | 88 | */ |
89 | - public function setParams(array $params){ |
|
89 | + public function setParams(array $params) { |
|
90 | 90 | $this->params = $params; |
91 | 91 | |
92 | 92 | return $this; |
@@ -98,7 +98,7 @@ discard block |
||
98 | 98 | * @return array the params |
99 | 99 | * @since 6.0.0 |
100 | 100 | */ |
101 | - public function getParams(){ |
|
101 | + public function getParams() { |
|
102 | 102 | return $this->params; |
103 | 103 | } |
104 | 104 | |
@@ -108,7 +108,7 @@ discard block |
||
108 | 108 | * @return string the name of the used template |
109 | 109 | * @since 6.0.0 |
110 | 110 | */ |
111 | - public function getTemplateName(){ |
|
111 | + public function getTemplateName() { |
|
112 | 112 | return $this->templateName; |
113 | 113 | } |
114 | 114 | |
@@ -122,7 +122,7 @@ discard block |
||
122 | 122 | * @return TemplateResponse Reference to this object |
123 | 123 | * @since 6.0.0 - return value was added in 7.0.0 |
124 | 124 | */ |
125 | - public function renderAs($renderAs){ |
|
125 | + public function renderAs($renderAs) { |
|
126 | 126 | $this->renderAs = $renderAs; |
127 | 127 | |
128 | 128 | return $this; |
@@ -134,7 +134,7 @@ discard block |
||
134 | 134 | * @return string the renderAs value |
135 | 135 | * @since 6.0.0 |
136 | 136 | */ |
137 | - public function getRenderAs(){ |
|
137 | + public function getRenderAs() { |
|
138 | 138 | return $this->renderAs; |
139 | 139 | } |
140 | 140 | |
@@ -144,13 +144,13 @@ discard block |
||
144 | 144 | * @return string the rendered html |
145 | 145 | * @since 6.0.0 |
146 | 146 | */ |
147 | - public function render(){ |
|
147 | + public function render() { |
|
148 | 148 | // \OCP\Template needs an empty string instead of 'blank' for an unwrapped response |
149 | 149 | $renderAs = $this->renderAs === 'blank' ? '' : $this->renderAs; |
150 | 150 | |
151 | 151 | $template = new \OCP\Template($this->appName, $this->templateName, $renderAs); |
152 | 152 | |
153 | - foreach($this->params as $key => $value){ |
|
153 | + foreach ($this->params as $key => $value) { |
|
154 | 154 | $template->assign($key, $value); |
155 | 155 | } |
156 | 156 |
@@ -33,33 +33,33 @@ |
||
33 | 33 | * @since 8.1.0 |
34 | 34 | */ |
35 | 35 | class StreamResponse extends Response implements ICallbackResponse { |
36 | - /** @var string */ |
|
37 | - private $filePath; |
|
36 | + /** @var string */ |
|
37 | + private $filePath; |
|
38 | 38 | |
39 | - /** |
|
40 | - * @param string $filePath the path to the file which should be streamed |
|
41 | - * @since 8.1.0 |
|
42 | - */ |
|
43 | - public function __construct ($filePath) { |
|
44 | - $this->filePath = $filePath; |
|
45 | - } |
|
39 | + /** |
|
40 | + * @param string $filePath the path to the file which should be streamed |
|
41 | + * @since 8.1.0 |
|
42 | + */ |
|
43 | + public function __construct ($filePath) { |
|
44 | + $this->filePath = $filePath; |
|
45 | + } |
|
46 | 46 | |
47 | 47 | |
48 | - /** |
|
49 | - * Streams the file using readfile |
|
50 | - * |
|
51 | - * @param IOutput $output a small wrapper that handles output |
|
52 | - * @since 8.1.0 |
|
53 | - */ |
|
54 | - public function callback (IOutput $output) { |
|
55 | - // handle caching |
|
56 | - if ($output->getHttpResponseCode() !== Http::STATUS_NOT_MODIFIED) { |
|
57 | - if (!file_exists($this->filePath)) { |
|
58 | - $output->setHttpResponseCode(Http::STATUS_NOT_FOUND); |
|
59 | - } elseif ($output->setReadfile($this->filePath) === false) { |
|
60 | - $output->setHttpResponseCode(Http::STATUS_BAD_REQUEST); |
|
61 | - } |
|
62 | - } |
|
63 | - } |
|
48 | + /** |
|
49 | + * Streams the file using readfile |
|
50 | + * |
|
51 | + * @param IOutput $output a small wrapper that handles output |
|
52 | + * @since 8.1.0 |
|
53 | + */ |
|
54 | + public function callback (IOutput $output) { |
|
55 | + // handle caching |
|
56 | + if ($output->getHttpResponseCode() !== Http::STATUS_NOT_MODIFIED) { |
|
57 | + if (!file_exists($this->filePath)) { |
|
58 | + $output->setHttpResponseCode(Http::STATUS_NOT_FOUND); |
|
59 | + } elseif ($output->setReadfile($this->filePath) === false) { |
|
60 | + $output->setHttpResponseCode(Http::STATUS_BAD_REQUEST); |
|
61 | + } |
|
62 | + } |
|
63 | + } |
|
64 | 64 | |
65 | 65 | } |
@@ -40,7 +40,7 @@ discard block |
||
40 | 40 | * @param string $filePath the path to the file which should be streamed |
41 | 41 | * @since 8.1.0 |
42 | 42 | */ |
43 | - public function __construct ($filePath) { |
|
43 | + public function __construct($filePath) { |
|
44 | 44 | $this->filePath = $filePath; |
45 | 45 | } |
46 | 46 | |
@@ -51,7 +51,7 @@ discard block |
||
51 | 51 | * @param IOutput $output a small wrapper that handles output |
52 | 52 | * @since 8.1.0 |
53 | 53 | */ |
54 | - public function callback (IOutput $output) { |
|
54 | + public function callback(IOutput $output) { |
|
55 | 55 | // handle caching |
56 | 56 | if ($output->getHttpResponseCode() !== Http::STATUS_NOT_MODIFIED) { |
57 | 57 | if (!file_exists($this->filePath)) { |
@@ -33,57 +33,57 @@ |
||
33 | 33 | */ |
34 | 34 | class DataDisplayResponse extends Response { |
35 | 35 | |
36 | - /** |
|
37 | - * response data |
|
38 | - * @var string; |
|
39 | - */ |
|
40 | - protected $data; |
|
36 | + /** |
|
37 | + * response data |
|
38 | + * @var string; |
|
39 | + */ |
|
40 | + protected $data; |
|
41 | 41 | |
42 | 42 | |
43 | - /** |
|
44 | - * @param string $data the data to display |
|
45 | - * @param int $statusCode the Http status code, defaults to 200 |
|
46 | - * @param array $headers additional key value based headers |
|
47 | - * @since 8.1.0 |
|
48 | - */ |
|
49 | - public function __construct($data="", $statusCode=Http::STATUS_OK, |
|
50 | - $headers=[]) { |
|
51 | - $this->data = $data; |
|
52 | - $this->setStatus($statusCode); |
|
53 | - $this->setHeaders(array_merge($this->getHeaders(), $headers)); |
|
54 | - $this->addHeader('Content-Disposition', 'inline; filename=""'); |
|
55 | - } |
|
43 | + /** |
|
44 | + * @param string $data the data to display |
|
45 | + * @param int $statusCode the Http status code, defaults to 200 |
|
46 | + * @param array $headers additional key value based headers |
|
47 | + * @since 8.1.0 |
|
48 | + */ |
|
49 | + public function __construct($data="", $statusCode=Http::STATUS_OK, |
|
50 | + $headers=[]) { |
|
51 | + $this->data = $data; |
|
52 | + $this->setStatus($statusCode); |
|
53 | + $this->setHeaders(array_merge($this->getHeaders(), $headers)); |
|
54 | + $this->addHeader('Content-Disposition', 'inline; filename=""'); |
|
55 | + } |
|
56 | 56 | |
57 | - /** |
|
58 | - * Outputs data. No processing is done. |
|
59 | - * @return string |
|
60 | - * @since 8.1.0 |
|
61 | - */ |
|
62 | - public function render() { |
|
63 | - return $this->data; |
|
64 | - } |
|
57 | + /** |
|
58 | + * Outputs data. No processing is done. |
|
59 | + * @return string |
|
60 | + * @since 8.1.0 |
|
61 | + */ |
|
62 | + public function render() { |
|
63 | + return $this->data; |
|
64 | + } |
|
65 | 65 | |
66 | 66 | |
67 | - /** |
|
68 | - * Sets values in the data |
|
69 | - * @param string $data the data to display |
|
70 | - * @return DataDisplayResponse Reference to this object |
|
71 | - * @since 8.1.0 |
|
72 | - */ |
|
73 | - public function setData($data){ |
|
74 | - $this->data = $data; |
|
67 | + /** |
|
68 | + * Sets values in the data |
|
69 | + * @param string $data the data to display |
|
70 | + * @return DataDisplayResponse Reference to this object |
|
71 | + * @since 8.1.0 |
|
72 | + */ |
|
73 | + public function setData($data){ |
|
74 | + $this->data = $data; |
|
75 | 75 | |
76 | - return $this; |
|
77 | - } |
|
76 | + return $this; |
|
77 | + } |
|
78 | 78 | |
79 | 79 | |
80 | - /** |
|
81 | - * Used to get the set parameters |
|
82 | - * @return string the data |
|
83 | - * @since 8.1.0 |
|
84 | - */ |
|
85 | - public function getData(){ |
|
86 | - return $this->data; |
|
87 | - } |
|
80 | + /** |
|
81 | + * Used to get the set parameters |
|
82 | + * @return string the data |
|
83 | + * @since 8.1.0 |
|
84 | + */ |
|
85 | + public function getData(){ |
|
86 | + return $this->data; |
|
87 | + } |
|
88 | 88 | |
89 | 89 | } |
@@ -46,8 +46,8 @@ discard block |
||
46 | 46 | * @param array $headers additional key value based headers |
47 | 47 | * @since 8.1.0 |
48 | 48 | */ |
49 | - public function __construct($data="", $statusCode=Http::STATUS_OK, |
|
50 | - $headers=[]) { |
|
49 | + public function __construct($data = "", $statusCode = Http::STATUS_OK, |
|
50 | + $headers = []) { |
|
51 | 51 | $this->data = $data; |
52 | 52 | $this->setStatus($statusCode); |
53 | 53 | $this->setHeaders(array_merge($this->getHeaders(), $headers)); |
@@ -70,7 +70,7 @@ discard block |
||
70 | 70 | * @return DataDisplayResponse Reference to this object |
71 | 71 | * @since 8.1.0 |
72 | 72 | */ |
73 | - public function setData($data){ |
|
73 | + public function setData($data) { |
|
74 | 74 | $this->data = $data; |
75 | 75 | |
76 | 76 | return $this; |
@@ -82,7 +82,7 @@ discard block |
||
82 | 82 | * @return string the data |
83 | 83 | * @since 8.1.0 |
84 | 84 | */ |
85 | - public function getData(){ |
|
85 | + public function getData() { |
|
86 | 86 | return $this->data; |
87 | 87 | } |
88 | 88 |
@@ -36,351 +36,351 @@ |
||
36 | 36 | * @since 9.0.0 |
37 | 37 | */ |
38 | 38 | class EmptyContentSecurityPolicy { |
39 | - /** @var bool Whether inline JS snippets are allowed */ |
|
40 | - protected $inlineScriptAllowed = null; |
|
41 | - /** |
|
42 | - * @var bool Whether eval in JS scripts is allowed |
|
43 | - * TODO: Disallow per default |
|
44 | - * @link https://github.com/owncloud/core/issues/11925 |
|
45 | - */ |
|
46 | - protected $evalScriptAllowed = null; |
|
47 | - /** @var array Domains from which scripts can get loaded */ |
|
48 | - protected $allowedScriptDomains = null; |
|
49 | - /** |
|
50 | - * @var bool Whether inline CSS is allowed |
|
51 | - * TODO: Disallow per default |
|
52 | - * @link https://github.com/owncloud/core/issues/13458 |
|
53 | - */ |
|
54 | - protected $inlineStyleAllowed = null; |
|
55 | - /** @var array Domains from which CSS can get loaded */ |
|
56 | - protected $allowedStyleDomains = null; |
|
57 | - /** @var array Domains from which images can get loaded */ |
|
58 | - protected $allowedImageDomains = null; |
|
59 | - /** @var array Domains to which connections can be done */ |
|
60 | - protected $allowedConnectDomains = null; |
|
61 | - /** @var array Domains from which media elements can be loaded */ |
|
62 | - protected $allowedMediaDomains = null; |
|
63 | - /** @var array Domains from which object elements can be loaded */ |
|
64 | - protected $allowedObjectDomains = null; |
|
65 | - /** @var array Domains from which iframes can be loaded */ |
|
66 | - protected $allowedFrameDomains = null; |
|
67 | - /** @var array Domains from which fonts can be loaded */ |
|
68 | - protected $allowedFontDomains = null; |
|
69 | - /** @var array Domains from which web-workers and nested browsing content can load elements */ |
|
70 | - protected $allowedChildSrcDomains = null; |
|
71 | - |
|
72 | - /** |
|
73 | - * Whether inline JavaScript snippets are allowed or forbidden |
|
74 | - * @param bool $state |
|
75 | - * @return $this |
|
76 | - * @since 8.1.0 |
|
77 | - */ |
|
78 | - public function allowInlineScript($state = false) { |
|
79 | - $this->inlineScriptAllowed = $state; |
|
80 | - return $this; |
|
81 | - } |
|
82 | - |
|
83 | - /** |
|
84 | - * Whether eval in JavaScript is allowed or forbidden |
|
85 | - * @param bool $state |
|
86 | - * @return $this |
|
87 | - * @since 8.1.0 |
|
88 | - */ |
|
89 | - public function allowEvalScript($state = true) { |
|
90 | - $this->evalScriptAllowed = $state; |
|
91 | - return $this; |
|
92 | - } |
|
93 | - |
|
94 | - /** |
|
95 | - * Allows to execute JavaScript files from a specific domain. Use * to |
|
96 | - * allow JavaScript from all domains. |
|
97 | - * @param string $domain Domain to whitelist. Any passed value needs to be properly sanitized. |
|
98 | - * @return $this |
|
99 | - * @since 8.1.0 |
|
100 | - */ |
|
101 | - public function addAllowedScriptDomain($domain) { |
|
102 | - $this->allowedScriptDomains[] = $domain; |
|
103 | - return $this; |
|
104 | - } |
|
105 | - |
|
106 | - /** |
|
107 | - * Remove the specified allowed script domain from the allowed domains. |
|
108 | - * |
|
109 | - * @param string $domain |
|
110 | - * @return $this |
|
111 | - * @since 8.1.0 |
|
112 | - */ |
|
113 | - public function disallowScriptDomain($domain) { |
|
114 | - $this->allowedScriptDomains = array_diff($this->allowedScriptDomains, [$domain]); |
|
115 | - return $this; |
|
116 | - } |
|
117 | - |
|
118 | - /** |
|
119 | - * Whether inline CSS snippets are allowed or forbidden |
|
120 | - * @param bool $state |
|
121 | - * @return $this |
|
122 | - * @since 8.1.0 |
|
123 | - */ |
|
124 | - public function allowInlineStyle($state = true) { |
|
125 | - $this->inlineStyleAllowed = $state; |
|
126 | - return $this; |
|
127 | - } |
|
128 | - |
|
129 | - /** |
|
130 | - * Allows to execute CSS files from a specific domain. Use * to allow |
|
131 | - * CSS from all domains. |
|
132 | - * @param string $domain Domain to whitelist. Any passed value needs to be properly sanitized. |
|
133 | - * @return $this |
|
134 | - * @since 8.1.0 |
|
135 | - */ |
|
136 | - public function addAllowedStyleDomain($domain) { |
|
137 | - $this->allowedStyleDomains[] = $domain; |
|
138 | - return $this; |
|
139 | - } |
|
140 | - |
|
141 | - /** |
|
142 | - * Remove the specified allowed style domain from the allowed domains. |
|
143 | - * |
|
144 | - * @param string $domain |
|
145 | - * @return $this |
|
146 | - * @since 8.1.0 |
|
147 | - */ |
|
148 | - public function disallowStyleDomain($domain) { |
|
149 | - $this->allowedStyleDomains = array_diff($this->allowedStyleDomains, [$domain]); |
|
150 | - return $this; |
|
151 | - } |
|
152 | - |
|
153 | - /** |
|
154 | - * Allows using fonts from a specific domain. Use * to allow |
|
155 | - * fonts from all domains. |
|
156 | - * @param string $domain Domain to whitelist. Any passed value needs to be properly sanitized. |
|
157 | - * @return $this |
|
158 | - * @since 8.1.0 |
|
159 | - */ |
|
160 | - public function addAllowedFontDomain($domain) { |
|
161 | - $this->allowedFontDomains[] = $domain; |
|
162 | - return $this; |
|
163 | - } |
|
164 | - |
|
165 | - /** |
|
166 | - * Remove the specified allowed font domain from the allowed domains. |
|
167 | - * |
|
168 | - * @param string $domain |
|
169 | - * @return $this |
|
170 | - * @since 8.1.0 |
|
171 | - */ |
|
172 | - public function disallowFontDomain($domain) { |
|
173 | - $this->allowedFontDomains = array_diff($this->allowedFontDomains, [$domain]); |
|
174 | - return $this; |
|
175 | - } |
|
176 | - |
|
177 | - /** |
|
178 | - * Allows embedding images from a specific domain. Use * to allow |
|
179 | - * images from all domains. |
|
180 | - * @param string $domain Domain to whitelist. Any passed value needs to be properly sanitized. |
|
181 | - * @return $this |
|
182 | - * @since 8.1.0 |
|
183 | - */ |
|
184 | - public function addAllowedImageDomain($domain) { |
|
185 | - $this->allowedImageDomains[] = $domain; |
|
186 | - return $this; |
|
187 | - } |
|
188 | - |
|
189 | - /** |
|
190 | - * Remove the specified allowed image domain from the allowed domains. |
|
191 | - * |
|
192 | - * @param string $domain |
|
193 | - * @return $this |
|
194 | - * @since 8.1.0 |
|
195 | - */ |
|
196 | - public function disallowImageDomain($domain) { |
|
197 | - $this->allowedImageDomains = array_diff($this->allowedImageDomains, [$domain]); |
|
198 | - return $this; |
|
199 | - } |
|
200 | - |
|
201 | - /** |
|
202 | - * To which remote domains the JS connect to. |
|
203 | - * @param string $domain Domain to whitelist. Any passed value needs to be properly sanitized. |
|
204 | - * @return $this |
|
205 | - * @since 8.1.0 |
|
206 | - */ |
|
207 | - public function addAllowedConnectDomain($domain) { |
|
208 | - $this->allowedConnectDomains[] = $domain; |
|
209 | - return $this; |
|
210 | - } |
|
211 | - |
|
212 | - /** |
|
213 | - * Remove the specified allowed connect domain from the allowed domains. |
|
214 | - * |
|
215 | - * @param string $domain |
|
216 | - * @return $this |
|
217 | - * @since 8.1.0 |
|
218 | - */ |
|
219 | - public function disallowConnectDomain($domain) { |
|
220 | - $this->allowedConnectDomains = array_diff($this->allowedConnectDomains, [$domain]); |
|
221 | - return $this; |
|
222 | - } |
|
223 | - |
|
224 | - /** |
|
225 | - * From which domains media elements can be embedded. |
|
226 | - * @param string $domain Domain to whitelist. Any passed value needs to be properly sanitized. |
|
227 | - * @return $this |
|
228 | - * @since 8.1.0 |
|
229 | - */ |
|
230 | - public function addAllowedMediaDomain($domain) { |
|
231 | - $this->allowedMediaDomains[] = $domain; |
|
232 | - return $this; |
|
233 | - } |
|
234 | - |
|
235 | - /** |
|
236 | - * Remove the specified allowed media domain from the allowed domains. |
|
237 | - * |
|
238 | - * @param string $domain |
|
239 | - * @return $this |
|
240 | - * @since 8.1.0 |
|
241 | - */ |
|
242 | - public function disallowMediaDomain($domain) { |
|
243 | - $this->allowedMediaDomains = array_diff($this->allowedMediaDomains, [$domain]); |
|
244 | - return $this; |
|
245 | - } |
|
246 | - |
|
247 | - /** |
|
248 | - * From which domains objects such as <object>, <embed> or <applet> are executed |
|
249 | - * @param string $domain Domain to whitelist. Any passed value needs to be properly sanitized. |
|
250 | - * @return $this |
|
251 | - * @since 8.1.0 |
|
252 | - */ |
|
253 | - public function addAllowedObjectDomain($domain) { |
|
254 | - $this->allowedObjectDomains[] = $domain; |
|
255 | - return $this; |
|
256 | - } |
|
257 | - |
|
258 | - /** |
|
259 | - * Remove the specified allowed object domain from the allowed domains. |
|
260 | - * |
|
261 | - * @param string $domain |
|
262 | - * @return $this |
|
263 | - * @since 8.1.0 |
|
264 | - */ |
|
265 | - public function disallowObjectDomain($domain) { |
|
266 | - $this->allowedObjectDomains = array_diff($this->allowedObjectDomains, [$domain]); |
|
267 | - return $this; |
|
268 | - } |
|
269 | - |
|
270 | - /** |
|
271 | - * Which domains can be embedded in an iframe |
|
272 | - * @param string $domain Domain to whitelist. Any passed value needs to be properly sanitized. |
|
273 | - * @return $this |
|
274 | - * @since 8.1.0 |
|
275 | - */ |
|
276 | - public function addAllowedFrameDomain($domain) { |
|
277 | - $this->allowedFrameDomains[] = $domain; |
|
278 | - return $this; |
|
279 | - } |
|
280 | - |
|
281 | - /** |
|
282 | - * Remove the specified allowed frame domain from the allowed domains. |
|
283 | - * |
|
284 | - * @param string $domain |
|
285 | - * @return $this |
|
286 | - * @since 8.1.0 |
|
287 | - */ |
|
288 | - public function disallowFrameDomain($domain) { |
|
289 | - $this->allowedFrameDomains = array_diff($this->allowedFrameDomains, [$domain]); |
|
290 | - return $this; |
|
291 | - } |
|
292 | - |
|
293 | - /** |
|
294 | - * Domains from which web-workers and nested browsing content can load elements |
|
295 | - * @param string $domain Domain to whitelist. Any passed value needs to be properly sanitized. |
|
296 | - * @return $this |
|
297 | - * @since 8.1.0 |
|
298 | - */ |
|
299 | - public function addAllowedChildSrcDomain($domain) { |
|
300 | - $this->allowedChildSrcDomains[] = $domain; |
|
301 | - return $this; |
|
302 | - } |
|
303 | - |
|
304 | - /** |
|
305 | - * Remove the specified allowed child src domain from the allowed domains. |
|
306 | - * |
|
307 | - * @param string $domain |
|
308 | - * @return $this |
|
309 | - * @since 8.1.0 |
|
310 | - */ |
|
311 | - public function disallowChildSrcDomain($domain) { |
|
312 | - $this->allowedChildSrcDomains = array_diff($this->allowedChildSrcDomains, [$domain]); |
|
313 | - return $this; |
|
314 | - } |
|
315 | - |
|
316 | - /** |
|
317 | - * Get the generated Content-Security-Policy as a string |
|
318 | - * @return string |
|
319 | - * @since 8.1.0 |
|
320 | - */ |
|
321 | - public function buildPolicy() { |
|
322 | - $policy = "default-src 'none';"; |
|
323 | - |
|
324 | - if(!empty($this->allowedScriptDomains) || $this->inlineScriptAllowed || $this->evalScriptAllowed) { |
|
325 | - $policy .= 'script-src '; |
|
326 | - if(is_array($this->allowedScriptDomains)) { |
|
327 | - $policy .= implode(' ', $this->allowedScriptDomains); |
|
328 | - } |
|
329 | - if($this->inlineScriptAllowed) { |
|
330 | - $policy .= ' \'unsafe-inline\''; |
|
331 | - } |
|
332 | - if($this->evalScriptAllowed) { |
|
333 | - $policy .= ' \'unsafe-eval\''; |
|
334 | - } |
|
335 | - $policy .= ';'; |
|
336 | - } |
|
337 | - |
|
338 | - if(!empty($this->allowedStyleDomains) || $this->inlineStyleAllowed) { |
|
339 | - $policy .= 'style-src '; |
|
340 | - if(is_array($this->allowedStyleDomains)) { |
|
341 | - $policy .= implode(' ', $this->allowedStyleDomains); |
|
342 | - } |
|
343 | - if($this->inlineStyleAllowed) { |
|
344 | - $policy .= ' \'unsafe-inline\''; |
|
345 | - } |
|
346 | - $policy .= ';'; |
|
347 | - } |
|
348 | - |
|
349 | - if(!empty($this->allowedImageDomains)) { |
|
350 | - $policy .= 'img-src ' . implode(' ', $this->allowedImageDomains); |
|
351 | - $policy .= ';'; |
|
352 | - } |
|
353 | - |
|
354 | - if(!empty($this->allowedFontDomains)) { |
|
355 | - $policy .= 'font-src ' . implode(' ', $this->allowedFontDomains); |
|
356 | - $policy .= ';'; |
|
357 | - } |
|
358 | - |
|
359 | - if(!empty($this->allowedConnectDomains)) { |
|
360 | - $policy .= 'connect-src ' . implode(' ', $this->allowedConnectDomains); |
|
361 | - $policy .= ';'; |
|
362 | - } |
|
363 | - |
|
364 | - if(!empty($this->allowedMediaDomains)) { |
|
365 | - $policy .= 'media-src ' . implode(' ', $this->allowedMediaDomains); |
|
366 | - $policy .= ';'; |
|
367 | - } |
|
368 | - |
|
369 | - if(!empty($this->allowedObjectDomains)) { |
|
370 | - $policy .= 'object-src ' . implode(' ', $this->allowedObjectDomains); |
|
371 | - $policy .= ';'; |
|
372 | - } |
|
373 | - |
|
374 | - if(!empty($this->allowedFrameDomains)) { |
|
375 | - $policy .= 'frame-src ' . implode(' ', $this->allowedFrameDomains); |
|
376 | - $policy .= ';'; |
|
377 | - } |
|
378 | - |
|
379 | - if(!empty($this->allowedChildSrcDomains)) { |
|
380 | - $policy .= 'child-src ' . implode(' ', $this->allowedChildSrcDomains); |
|
381 | - $policy .= ';'; |
|
382 | - } |
|
383 | - |
|
384 | - return rtrim($policy, ';'); |
|
385 | - } |
|
39 | + /** @var bool Whether inline JS snippets are allowed */ |
|
40 | + protected $inlineScriptAllowed = null; |
|
41 | + /** |
|
42 | + * @var bool Whether eval in JS scripts is allowed |
|
43 | + * TODO: Disallow per default |
|
44 | + * @link https://github.com/owncloud/core/issues/11925 |
|
45 | + */ |
|
46 | + protected $evalScriptAllowed = null; |
|
47 | + /** @var array Domains from which scripts can get loaded */ |
|
48 | + protected $allowedScriptDomains = null; |
|
49 | + /** |
|
50 | + * @var bool Whether inline CSS is allowed |
|
51 | + * TODO: Disallow per default |
|
52 | + * @link https://github.com/owncloud/core/issues/13458 |
|
53 | + */ |
|
54 | + protected $inlineStyleAllowed = null; |
|
55 | + /** @var array Domains from which CSS can get loaded */ |
|
56 | + protected $allowedStyleDomains = null; |
|
57 | + /** @var array Domains from which images can get loaded */ |
|
58 | + protected $allowedImageDomains = null; |
|
59 | + /** @var array Domains to which connections can be done */ |
|
60 | + protected $allowedConnectDomains = null; |
|
61 | + /** @var array Domains from which media elements can be loaded */ |
|
62 | + protected $allowedMediaDomains = null; |
|
63 | + /** @var array Domains from which object elements can be loaded */ |
|
64 | + protected $allowedObjectDomains = null; |
|
65 | + /** @var array Domains from which iframes can be loaded */ |
|
66 | + protected $allowedFrameDomains = null; |
|
67 | + /** @var array Domains from which fonts can be loaded */ |
|
68 | + protected $allowedFontDomains = null; |
|
69 | + /** @var array Domains from which web-workers and nested browsing content can load elements */ |
|
70 | + protected $allowedChildSrcDomains = null; |
|
71 | + |
|
72 | + /** |
|
73 | + * Whether inline JavaScript snippets are allowed or forbidden |
|
74 | + * @param bool $state |
|
75 | + * @return $this |
|
76 | + * @since 8.1.0 |
|
77 | + */ |
|
78 | + public function allowInlineScript($state = false) { |
|
79 | + $this->inlineScriptAllowed = $state; |
|
80 | + return $this; |
|
81 | + } |
|
82 | + |
|
83 | + /** |
|
84 | + * Whether eval in JavaScript is allowed or forbidden |
|
85 | + * @param bool $state |
|
86 | + * @return $this |
|
87 | + * @since 8.1.0 |
|
88 | + */ |
|
89 | + public function allowEvalScript($state = true) { |
|
90 | + $this->evalScriptAllowed = $state; |
|
91 | + return $this; |
|
92 | + } |
|
93 | + |
|
94 | + /** |
|
95 | + * Allows to execute JavaScript files from a specific domain. Use * to |
|
96 | + * allow JavaScript from all domains. |
|
97 | + * @param string $domain Domain to whitelist. Any passed value needs to be properly sanitized. |
|
98 | + * @return $this |
|
99 | + * @since 8.1.0 |
|
100 | + */ |
|
101 | + public function addAllowedScriptDomain($domain) { |
|
102 | + $this->allowedScriptDomains[] = $domain; |
|
103 | + return $this; |
|
104 | + } |
|
105 | + |
|
106 | + /** |
|
107 | + * Remove the specified allowed script domain from the allowed domains. |
|
108 | + * |
|
109 | + * @param string $domain |
|
110 | + * @return $this |
|
111 | + * @since 8.1.0 |
|
112 | + */ |
|
113 | + public function disallowScriptDomain($domain) { |
|
114 | + $this->allowedScriptDomains = array_diff($this->allowedScriptDomains, [$domain]); |
|
115 | + return $this; |
|
116 | + } |
|
117 | + |
|
118 | + /** |
|
119 | + * Whether inline CSS snippets are allowed or forbidden |
|
120 | + * @param bool $state |
|
121 | + * @return $this |
|
122 | + * @since 8.1.0 |
|
123 | + */ |
|
124 | + public function allowInlineStyle($state = true) { |
|
125 | + $this->inlineStyleAllowed = $state; |
|
126 | + return $this; |
|
127 | + } |
|
128 | + |
|
129 | + /** |
|
130 | + * Allows to execute CSS files from a specific domain. Use * to allow |
|
131 | + * CSS from all domains. |
|
132 | + * @param string $domain Domain to whitelist. Any passed value needs to be properly sanitized. |
|
133 | + * @return $this |
|
134 | + * @since 8.1.0 |
|
135 | + */ |
|
136 | + public function addAllowedStyleDomain($domain) { |
|
137 | + $this->allowedStyleDomains[] = $domain; |
|
138 | + return $this; |
|
139 | + } |
|
140 | + |
|
141 | + /** |
|
142 | + * Remove the specified allowed style domain from the allowed domains. |
|
143 | + * |
|
144 | + * @param string $domain |
|
145 | + * @return $this |
|
146 | + * @since 8.1.0 |
|
147 | + */ |
|
148 | + public function disallowStyleDomain($domain) { |
|
149 | + $this->allowedStyleDomains = array_diff($this->allowedStyleDomains, [$domain]); |
|
150 | + return $this; |
|
151 | + } |
|
152 | + |
|
153 | + /** |
|
154 | + * Allows using fonts from a specific domain. Use * to allow |
|
155 | + * fonts from all domains. |
|
156 | + * @param string $domain Domain to whitelist. Any passed value needs to be properly sanitized. |
|
157 | + * @return $this |
|
158 | + * @since 8.1.0 |
|
159 | + */ |
|
160 | + public function addAllowedFontDomain($domain) { |
|
161 | + $this->allowedFontDomains[] = $domain; |
|
162 | + return $this; |
|
163 | + } |
|
164 | + |
|
165 | + /** |
|
166 | + * Remove the specified allowed font domain from the allowed domains. |
|
167 | + * |
|
168 | + * @param string $domain |
|
169 | + * @return $this |
|
170 | + * @since 8.1.0 |
|
171 | + */ |
|
172 | + public function disallowFontDomain($domain) { |
|
173 | + $this->allowedFontDomains = array_diff($this->allowedFontDomains, [$domain]); |
|
174 | + return $this; |
|
175 | + } |
|
176 | + |
|
177 | + /** |
|
178 | + * Allows embedding images from a specific domain. Use * to allow |
|
179 | + * images from all domains. |
|
180 | + * @param string $domain Domain to whitelist. Any passed value needs to be properly sanitized. |
|
181 | + * @return $this |
|
182 | + * @since 8.1.0 |
|
183 | + */ |
|
184 | + public function addAllowedImageDomain($domain) { |
|
185 | + $this->allowedImageDomains[] = $domain; |
|
186 | + return $this; |
|
187 | + } |
|
188 | + |
|
189 | + /** |
|
190 | + * Remove the specified allowed image domain from the allowed domains. |
|
191 | + * |
|
192 | + * @param string $domain |
|
193 | + * @return $this |
|
194 | + * @since 8.1.0 |
|
195 | + */ |
|
196 | + public function disallowImageDomain($domain) { |
|
197 | + $this->allowedImageDomains = array_diff($this->allowedImageDomains, [$domain]); |
|
198 | + return $this; |
|
199 | + } |
|
200 | + |
|
201 | + /** |
|
202 | + * To which remote domains the JS connect to. |
|
203 | + * @param string $domain Domain to whitelist. Any passed value needs to be properly sanitized. |
|
204 | + * @return $this |
|
205 | + * @since 8.1.0 |
|
206 | + */ |
|
207 | + public function addAllowedConnectDomain($domain) { |
|
208 | + $this->allowedConnectDomains[] = $domain; |
|
209 | + return $this; |
|
210 | + } |
|
211 | + |
|
212 | + /** |
|
213 | + * Remove the specified allowed connect domain from the allowed domains. |
|
214 | + * |
|
215 | + * @param string $domain |
|
216 | + * @return $this |
|
217 | + * @since 8.1.0 |
|
218 | + */ |
|
219 | + public function disallowConnectDomain($domain) { |
|
220 | + $this->allowedConnectDomains = array_diff($this->allowedConnectDomains, [$domain]); |
|
221 | + return $this; |
|
222 | + } |
|
223 | + |
|
224 | + /** |
|
225 | + * From which domains media elements can be embedded. |
|
226 | + * @param string $domain Domain to whitelist. Any passed value needs to be properly sanitized. |
|
227 | + * @return $this |
|
228 | + * @since 8.1.0 |
|
229 | + */ |
|
230 | + public function addAllowedMediaDomain($domain) { |
|
231 | + $this->allowedMediaDomains[] = $domain; |
|
232 | + return $this; |
|
233 | + } |
|
234 | + |
|
235 | + /** |
|
236 | + * Remove the specified allowed media domain from the allowed domains. |
|
237 | + * |
|
238 | + * @param string $domain |
|
239 | + * @return $this |
|
240 | + * @since 8.1.0 |
|
241 | + */ |
|
242 | + public function disallowMediaDomain($domain) { |
|
243 | + $this->allowedMediaDomains = array_diff($this->allowedMediaDomains, [$domain]); |
|
244 | + return $this; |
|
245 | + } |
|
246 | + |
|
247 | + /** |
|
248 | + * From which domains objects such as <object>, <embed> or <applet> are executed |
|
249 | + * @param string $domain Domain to whitelist. Any passed value needs to be properly sanitized. |
|
250 | + * @return $this |
|
251 | + * @since 8.1.0 |
|
252 | + */ |
|
253 | + public function addAllowedObjectDomain($domain) { |
|
254 | + $this->allowedObjectDomains[] = $domain; |
|
255 | + return $this; |
|
256 | + } |
|
257 | + |
|
258 | + /** |
|
259 | + * Remove the specified allowed object domain from the allowed domains. |
|
260 | + * |
|
261 | + * @param string $domain |
|
262 | + * @return $this |
|
263 | + * @since 8.1.0 |
|
264 | + */ |
|
265 | + public function disallowObjectDomain($domain) { |
|
266 | + $this->allowedObjectDomains = array_diff($this->allowedObjectDomains, [$domain]); |
|
267 | + return $this; |
|
268 | + } |
|
269 | + |
|
270 | + /** |
|
271 | + * Which domains can be embedded in an iframe |
|
272 | + * @param string $domain Domain to whitelist. Any passed value needs to be properly sanitized. |
|
273 | + * @return $this |
|
274 | + * @since 8.1.0 |
|
275 | + */ |
|
276 | + public function addAllowedFrameDomain($domain) { |
|
277 | + $this->allowedFrameDomains[] = $domain; |
|
278 | + return $this; |
|
279 | + } |
|
280 | + |
|
281 | + /** |
|
282 | + * Remove the specified allowed frame domain from the allowed domains. |
|
283 | + * |
|
284 | + * @param string $domain |
|
285 | + * @return $this |
|
286 | + * @since 8.1.0 |
|
287 | + */ |
|
288 | + public function disallowFrameDomain($domain) { |
|
289 | + $this->allowedFrameDomains = array_diff($this->allowedFrameDomains, [$domain]); |
|
290 | + return $this; |
|
291 | + } |
|
292 | + |
|
293 | + /** |
|
294 | + * Domains from which web-workers and nested browsing content can load elements |
|
295 | + * @param string $domain Domain to whitelist. Any passed value needs to be properly sanitized. |
|
296 | + * @return $this |
|
297 | + * @since 8.1.0 |
|
298 | + */ |
|
299 | + public function addAllowedChildSrcDomain($domain) { |
|
300 | + $this->allowedChildSrcDomains[] = $domain; |
|
301 | + return $this; |
|
302 | + } |
|
303 | + |
|
304 | + /** |
|
305 | + * Remove the specified allowed child src domain from the allowed domains. |
|
306 | + * |
|
307 | + * @param string $domain |
|
308 | + * @return $this |
|
309 | + * @since 8.1.0 |
|
310 | + */ |
|
311 | + public function disallowChildSrcDomain($domain) { |
|
312 | + $this->allowedChildSrcDomains = array_diff($this->allowedChildSrcDomains, [$domain]); |
|
313 | + return $this; |
|
314 | + } |
|
315 | + |
|
316 | + /** |
|
317 | + * Get the generated Content-Security-Policy as a string |
|
318 | + * @return string |
|
319 | + * @since 8.1.0 |
|
320 | + */ |
|
321 | + public function buildPolicy() { |
|
322 | + $policy = "default-src 'none';"; |
|
323 | + |
|
324 | + if(!empty($this->allowedScriptDomains) || $this->inlineScriptAllowed || $this->evalScriptAllowed) { |
|
325 | + $policy .= 'script-src '; |
|
326 | + if(is_array($this->allowedScriptDomains)) { |
|
327 | + $policy .= implode(' ', $this->allowedScriptDomains); |
|
328 | + } |
|
329 | + if($this->inlineScriptAllowed) { |
|
330 | + $policy .= ' \'unsafe-inline\''; |
|
331 | + } |
|
332 | + if($this->evalScriptAllowed) { |
|
333 | + $policy .= ' \'unsafe-eval\''; |
|
334 | + } |
|
335 | + $policy .= ';'; |
|
336 | + } |
|
337 | + |
|
338 | + if(!empty($this->allowedStyleDomains) || $this->inlineStyleAllowed) { |
|
339 | + $policy .= 'style-src '; |
|
340 | + if(is_array($this->allowedStyleDomains)) { |
|
341 | + $policy .= implode(' ', $this->allowedStyleDomains); |
|
342 | + } |
|
343 | + if($this->inlineStyleAllowed) { |
|
344 | + $policy .= ' \'unsafe-inline\''; |
|
345 | + } |
|
346 | + $policy .= ';'; |
|
347 | + } |
|
348 | + |
|
349 | + if(!empty($this->allowedImageDomains)) { |
|
350 | + $policy .= 'img-src ' . implode(' ', $this->allowedImageDomains); |
|
351 | + $policy .= ';'; |
|
352 | + } |
|
353 | + |
|
354 | + if(!empty($this->allowedFontDomains)) { |
|
355 | + $policy .= 'font-src ' . implode(' ', $this->allowedFontDomains); |
|
356 | + $policy .= ';'; |
|
357 | + } |
|
358 | + |
|
359 | + if(!empty($this->allowedConnectDomains)) { |
|
360 | + $policy .= 'connect-src ' . implode(' ', $this->allowedConnectDomains); |
|
361 | + $policy .= ';'; |
|
362 | + } |
|
363 | + |
|
364 | + if(!empty($this->allowedMediaDomains)) { |
|
365 | + $policy .= 'media-src ' . implode(' ', $this->allowedMediaDomains); |
|
366 | + $policy .= ';'; |
|
367 | + } |
|
368 | + |
|
369 | + if(!empty($this->allowedObjectDomains)) { |
|
370 | + $policy .= 'object-src ' . implode(' ', $this->allowedObjectDomains); |
|
371 | + $policy .= ';'; |
|
372 | + } |
|
373 | + |
|
374 | + if(!empty($this->allowedFrameDomains)) { |
|
375 | + $policy .= 'frame-src ' . implode(' ', $this->allowedFrameDomains); |
|
376 | + $policy .= ';'; |
|
377 | + } |
|
378 | + |
|
379 | + if(!empty($this->allowedChildSrcDomains)) { |
|
380 | + $policy .= 'child-src ' . implode(' ', $this->allowedChildSrcDomains); |
|
381 | + $policy .= ';'; |
|
382 | + } |
|
383 | + |
|
384 | + return rtrim($policy, ';'); |
|
385 | + } |
|
386 | 386 | } |
@@ -321,63 +321,63 @@ |
||
321 | 321 | public function buildPolicy() { |
322 | 322 | $policy = "default-src 'none';"; |
323 | 323 | |
324 | - if(!empty($this->allowedScriptDomains) || $this->inlineScriptAllowed || $this->evalScriptAllowed) { |
|
324 | + if (!empty($this->allowedScriptDomains) || $this->inlineScriptAllowed || $this->evalScriptAllowed) { |
|
325 | 325 | $policy .= 'script-src '; |
326 | - if(is_array($this->allowedScriptDomains)) { |
|
326 | + if (is_array($this->allowedScriptDomains)) { |
|
327 | 327 | $policy .= implode(' ', $this->allowedScriptDomains); |
328 | 328 | } |
329 | - if($this->inlineScriptAllowed) { |
|
329 | + if ($this->inlineScriptAllowed) { |
|
330 | 330 | $policy .= ' \'unsafe-inline\''; |
331 | 331 | } |
332 | - if($this->evalScriptAllowed) { |
|
332 | + if ($this->evalScriptAllowed) { |
|
333 | 333 | $policy .= ' \'unsafe-eval\''; |
334 | 334 | } |
335 | 335 | $policy .= ';'; |
336 | 336 | } |
337 | 337 | |
338 | - if(!empty($this->allowedStyleDomains) || $this->inlineStyleAllowed) { |
|
338 | + if (!empty($this->allowedStyleDomains) || $this->inlineStyleAllowed) { |
|
339 | 339 | $policy .= 'style-src '; |
340 | - if(is_array($this->allowedStyleDomains)) { |
|
340 | + if (is_array($this->allowedStyleDomains)) { |
|
341 | 341 | $policy .= implode(' ', $this->allowedStyleDomains); |
342 | 342 | } |
343 | - if($this->inlineStyleAllowed) { |
|
343 | + if ($this->inlineStyleAllowed) { |
|
344 | 344 | $policy .= ' \'unsafe-inline\''; |
345 | 345 | } |
346 | 346 | $policy .= ';'; |
347 | 347 | } |
348 | 348 | |
349 | - if(!empty($this->allowedImageDomains)) { |
|
350 | - $policy .= 'img-src ' . implode(' ', $this->allowedImageDomains); |
|
349 | + if (!empty($this->allowedImageDomains)) { |
|
350 | + $policy .= 'img-src '.implode(' ', $this->allowedImageDomains); |
|
351 | 351 | $policy .= ';'; |
352 | 352 | } |
353 | 353 | |
354 | - if(!empty($this->allowedFontDomains)) { |
|
355 | - $policy .= 'font-src ' . implode(' ', $this->allowedFontDomains); |
|
354 | + if (!empty($this->allowedFontDomains)) { |
|
355 | + $policy .= 'font-src '.implode(' ', $this->allowedFontDomains); |
|
356 | 356 | $policy .= ';'; |
357 | 357 | } |
358 | 358 | |
359 | - if(!empty($this->allowedConnectDomains)) { |
|
360 | - $policy .= 'connect-src ' . implode(' ', $this->allowedConnectDomains); |
|
359 | + if (!empty($this->allowedConnectDomains)) { |
|
360 | + $policy .= 'connect-src '.implode(' ', $this->allowedConnectDomains); |
|
361 | 361 | $policy .= ';'; |
362 | 362 | } |
363 | 363 | |
364 | - if(!empty($this->allowedMediaDomains)) { |
|
365 | - $policy .= 'media-src ' . implode(' ', $this->allowedMediaDomains); |
|
364 | + if (!empty($this->allowedMediaDomains)) { |
|
365 | + $policy .= 'media-src '.implode(' ', $this->allowedMediaDomains); |
|
366 | 366 | $policy .= ';'; |
367 | 367 | } |
368 | 368 | |
369 | - if(!empty($this->allowedObjectDomains)) { |
|
370 | - $policy .= 'object-src ' . implode(' ', $this->allowedObjectDomains); |
|
369 | + if (!empty($this->allowedObjectDomains)) { |
|
370 | + $policy .= 'object-src '.implode(' ', $this->allowedObjectDomains); |
|
371 | 371 | $policy .= ';'; |
372 | 372 | } |
373 | 373 | |
374 | - if(!empty($this->allowedFrameDomains)) { |
|
375 | - $policy .= 'frame-src ' . implode(' ', $this->allowedFrameDomains); |
|
374 | + if (!empty($this->allowedFrameDomains)) { |
|
375 | + $policy .= 'frame-src '.implode(' ', $this->allowedFrameDomains); |
|
376 | 376 | $policy .= ';'; |
377 | 377 | } |
378 | 378 | |
379 | - if(!empty($this->allowedChildSrcDomains)) { |
|
380 | - $policy .= 'child-src ' . implode(' ', $this->allowedChildSrcDomains); |
|
379 | + if (!empty($this->allowedChildSrcDomains)) { |
|
380 | + $policy .= 'child-src '.implode(' ', $this->allowedChildSrcDomains); |
|
381 | 381 | $policy .= ';'; |
382 | 382 | } |
383 | 383 |
@@ -39,63 +39,63 @@ |
||
39 | 39 | */ |
40 | 40 | class JSONResponse extends Response { |
41 | 41 | |
42 | - /** |
|
43 | - * response data |
|
44 | - * @var array|object |
|
45 | - */ |
|
46 | - protected $data; |
|
42 | + /** |
|
43 | + * response data |
|
44 | + * @var array|object |
|
45 | + */ |
|
46 | + protected $data; |
|
47 | 47 | |
48 | 48 | |
49 | - /** |
|
50 | - * constructor of JSONResponse |
|
51 | - * @param array|object $data the object or array that should be transformed |
|
52 | - * @param int $statusCode the Http status code, defaults to 200 |
|
53 | - * @since 6.0.0 |
|
54 | - */ |
|
55 | - public function __construct($data=array(), $statusCode=Http::STATUS_OK) { |
|
56 | - $this->data = $data; |
|
57 | - $this->setStatus($statusCode); |
|
58 | - $this->addHeader('Content-Type', 'application/json; charset=utf-8'); |
|
59 | - } |
|
49 | + /** |
|
50 | + * constructor of JSONResponse |
|
51 | + * @param array|object $data the object or array that should be transformed |
|
52 | + * @param int $statusCode the Http status code, defaults to 200 |
|
53 | + * @since 6.0.0 |
|
54 | + */ |
|
55 | + public function __construct($data=array(), $statusCode=Http::STATUS_OK) { |
|
56 | + $this->data = $data; |
|
57 | + $this->setStatus($statusCode); |
|
58 | + $this->addHeader('Content-Type', 'application/json; charset=utf-8'); |
|
59 | + } |
|
60 | 60 | |
61 | 61 | |
62 | - /** |
|
63 | - * Returns the rendered json |
|
64 | - * @return string the rendered json |
|
65 | - * @since 6.0.0 |
|
66 | - * @throws \Exception If data could not get encoded |
|
67 | - */ |
|
68 | - public function render() { |
|
69 | - $response = json_encode($this->data, JSON_HEX_TAG); |
|
70 | - if($response === false) { |
|
71 | - throw new \Exception(sprintf('Could not json_encode due to invalid ' . |
|
72 | - 'non UTF-8 characters in the array: %s', var_export($this->data, true))); |
|
73 | - } |
|
62 | + /** |
|
63 | + * Returns the rendered json |
|
64 | + * @return string the rendered json |
|
65 | + * @since 6.0.0 |
|
66 | + * @throws \Exception If data could not get encoded |
|
67 | + */ |
|
68 | + public function render() { |
|
69 | + $response = json_encode($this->data, JSON_HEX_TAG); |
|
70 | + if($response === false) { |
|
71 | + throw new \Exception(sprintf('Could not json_encode due to invalid ' . |
|
72 | + 'non UTF-8 characters in the array: %s', var_export($this->data, true))); |
|
73 | + } |
|
74 | 74 | |
75 | - return $response; |
|
76 | - } |
|
75 | + return $response; |
|
76 | + } |
|
77 | 77 | |
78 | - /** |
|
79 | - * Sets values in the data json array |
|
80 | - * @param array|object $data an array or object which will be transformed |
|
81 | - * to JSON |
|
82 | - * @return JSONResponse Reference to this object |
|
83 | - * @since 6.0.0 - return value was added in 7.0.0 |
|
84 | - */ |
|
85 | - public function setData($data){ |
|
86 | - $this->data = $data; |
|
78 | + /** |
|
79 | + * Sets values in the data json array |
|
80 | + * @param array|object $data an array or object which will be transformed |
|
81 | + * to JSON |
|
82 | + * @return JSONResponse Reference to this object |
|
83 | + * @since 6.0.0 - return value was added in 7.0.0 |
|
84 | + */ |
|
85 | + public function setData($data){ |
|
86 | + $this->data = $data; |
|
87 | 87 | |
88 | - return $this; |
|
89 | - } |
|
88 | + return $this; |
|
89 | + } |
|
90 | 90 | |
91 | 91 | |
92 | - /** |
|
93 | - * Used to get the set parameters |
|
94 | - * @return array the data |
|
95 | - * @since 6.0.0 |
|
96 | - */ |
|
97 | - public function getData(){ |
|
98 | - return $this->data; |
|
99 | - } |
|
92 | + /** |
|
93 | + * Used to get the set parameters |
|
94 | + * @return array the data |
|
95 | + * @since 6.0.0 |
|
96 | + */ |
|
97 | + public function getData(){ |
|
98 | + return $this->data; |
|
99 | + } |
|
100 | 100 | |
101 | 101 | } |
@@ -52,7 +52,7 @@ discard block |
||
52 | 52 | * @param int $statusCode the Http status code, defaults to 200 |
53 | 53 | * @since 6.0.0 |
54 | 54 | */ |
55 | - public function __construct($data=array(), $statusCode=Http::STATUS_OK) { |
|
55 | + public function __construct($data = array(), $statusCode = Http::STATUS_OK) { |
|
56 | 56 | $this->data = $data; |
57 | 57 | $this->setStatus($statusCode); |
58 | 58 | $this->addHeader('Content-Type', 'application/json; charset=utf-8'); |
@@ -67,8 +67,8 @@ discard block |
||
67 | 67 | */ |
68 | 68 | public function render() { |
69 | 69 | $response = json_encode($this->data, JSON_HEX_TAG); |
70 | - if($response === false) { |
|
71 | - throw new \Exception(sprintf('Could not json_encode due to invalid ' . |
|
70 | + if ($response === false) { |
|
71 | + throw new \Exception(sprintf('Could not json_encode due to invalid '. |
|
72 | 72 | 'non UTF-8 characters in the array: %s', var_export($this->data, true))); |
73 | 73 | } |
74 | 74 | |
@@ -82,7 +82,7 @@ discard block |
||
82 | 82 | * @return JSONResponse Reference to this object |
83 | 83 | * @since 6.0.0 - return value was added in 7.0.0 |
84 | 84 | */ |
85 | - public function setData($data){ |
|
85 | + public function setData($data) { |
|
86 | 86 | $this->data = $data; |
87 | 87 | |
88 | 88 | return $this; |
@@ -94,7 +94,7 @@ discard block |
||
94 | 94 | * @return array the data |
95 | 95 | * @since 6.0.0 |
96 | 96 | */ |
97 | - public function getData(){ |
|
97 | + public function getData() { |
|
98 | 98 | return $this->data; |
99 | 99 | } |
100 | 100 |