Passed
Push — master ( 96e892...5b0e70 )
by Roeland
13:09
created
lib/private/AppFramework/Middleware/Security/SecurityMiddleware.php 1 patch
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -142,17 +142,17 @@  discard block
 block discarded – undo
142 142
 
143 143
 		// security checks
144 144
 		$isPublicPage = $this->reflector->hasAnnotation('PublicPage');
145
-		if(!$isPublicPage) {
146
-			if(!$this->isLoggedIn) {
145
+		if (!$isPublicPage) {
146
+			if (!$this->isLoggedIn) {
147 147
 				throw new NotLoggedInException();
148 148
 			}
149 149
 
150
-			if($this->reflector->hasAnnotation('SubAdminRequired')
150
+			if ($this->reflector->hasAnnotation('SubAdminRequired')
151 151
 				&& !$this->isSubAdmin
152 152
 				&& !$this->isAdminUser) {
153 153
 				throw new NotAdminException($this->l10n->t('Logged in user must be an admin or sub admin'));
154 154
 			}
155
-			if(!$this->reflector->hasAnnotation('SubAdminRequired')
155
+			if (!$this->reflector->hasAnnotation('SubAdminRequired')
156 156
 				&& !$this->reflector->hasAnnotation('NoAdminRequired')
157 157
 				&& !$this->isAdminUser) {
158 158
 				throw new NotAdminException($this->l10n->t('Logged in user must be an admin'));
@@ -160,14 +160,14 @@  discard block
 block discarded – undo
160 160
 		}
161 161
 
162 162
 		// Check for strict cookie requirement
163
-		if($this->reflector->hasAnnotation('StrictCookieRequired') || !$this->reflector->hasAnnotation('NoCSRFRequired')) {
164
-			if(!$this->request->passesStrictCookieCheck()) {
163
+		if ($this->reflector->hasAnnotation('StrictCookieRequired') || !$this->reflector->hasAnnotation('NoCSRFRequired')) {
164
+			if (!$this->request->passesStrictCookieCheck()) {
165 165
 				throw new StrictCookieMissingException();
166 166
 			}
167 167
 		}
168 168
 		// CSRF check - also registers the CSRF token since the session may be closed later
169 169
 		Util::callRegister();
170
-		if(!$this->reflector->hasAnnotation('NoCSRFRequired')) {
170
+		if (!$this->reflector->hasAnnotation('NoCSRFRequired')) {
171 171
 			/*
172 172
 			 * Only allow the CSRF check to fail on OCS Requests. This kind of
173 173
 			 * hacks around that we have no full token auth in place yet and we
@@ -176,7 +176,7 @@  discard block
 block discarded – undo
176 176
 			 * Additionally we allow Bearer authenticated requests to pass on OCS routes.
177 177
 			 * This allows oauth apps (e.g. moodle) to use the OCS endpoints
178 178
 			 */
179
-			if(!$this->request->passesCSRFCheck() && !(
179
+			if (!$this->request->passesCSRFCheck() && !(
180 180
 					$controller instanceof OCSController && (
181 181
 						$this->request->getHeader('OCS-APIREQUEST') === 'true' ||
182 182
 						strpos($this->request->getHeader('Authorization'), 'Bearer ') === 0
@@ -222,7 +222,7 @@  discard block
 block discarded – undo
222 222
 		$defaultPolicy = $this->contentSecurityPolicyManager->getDefaultPolicy();
223 223
 		$defaultPolicy = $this->contentSecurityPolicyManager->mergePolicies($defaultPolicy, $policy);
224 224
 
225
-		if($this->cspNonceManager->browserSupportsCspV3()) {
225
+		if ($this->cspNonceManager->browserSupportsCspV3()) {
226 226
 			$defaultPolicy->useJsNonce($this->csrfTokenManager->getToken()->getEncryptedValue());
227 227
 		}
228 228
 
@@ -242,17 +242,17 @@  discard block
 block discarded – undo
242 242
 	 * @return Response a Response object or null in case that the exception could not be handled
243 243
 	 */
244 244
 	public function afterException($controller, $methodName, \Exception $exception): Response {
245
-		if($exception instanceof SecurityException) {
246
-			if($exception instanceof StrictCookieMissingException) {
245
+		if ($exception instanceof SecurityException) {
246
+			if ($exception instanceof StrictCookieMissingException) {
247 247
 				return new RedirectResponse(\OC::$WEBROOT);
248 248
  			}
249
-			if (stripos($this->request->getHeader('Accept'),'html') === false) {
249
+			if (stripos($this->request->getHeader('Accept'), 'html') === false) {
250 250
 				$response = new JSONResponse(
251 251
 					['message' => $exception->getMessage()],
252 252
 					$exception->getCode()
253 253
 				);
254 254
 			} else {
255
-				if($exception instanceof NotLoggedInException) {
255
+				if ($exception instanceof NotLoggedInException) {
256 256
 					$params = [];
257 257
 					if (isset($this->request->server['REQUEST_URI'])) {
258 258
 						$params['redirect_url'] = $this->request->server['REQUEST_URI'];
Please login to merge, or discard this patch.
settings/Controller/CommonSettingsTrait.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -34,7 +34,7 @@  discard block
 block discarded – undo
34 34
 use OCP\Settings\IIconSection;
35 35
 use OCP\Settings\ISettings;
36 36
 
37
-trait CommonSettingsTrait  {
37
+trait CommonSettingsTrait {
38 38
 
39 39
 	/** @var ISettingsManager */
40 40
 	private $settingsManager;
@@ -81,11 +81,11 @@  discard block
 block discarded – undo
81 81
 	protected function formatSections($sections, $currentSection, $type, $currentType, bool $subAdminOnly = false) {
82 82
 		$templateParameters = [];
83 83
 		/** @var \OCP\Settings\ISection[] $prioritizedSections */
84
-		foreach($sections as $prioritizedSections) {
84
+		foreach ($sections as $prioritizedSections) {
85 85
 			foreach ($prioritizedSections as $section) {
86
-				if($type === 'admin') {
86
+				if ($type === 'admin') {
87 87
 					$settings = $this->settingsManager->getAdminSettings($section->getID(), $subAdminOnly);
88
-				} else if($type === 'personal') {
88
+				} else if ($type === 'personal') {
89 89
 					$settings = $this->settingsManager->getPersonalSettings($section->getID());
90 90
 				}
91 91
 				if (empty($settings) && !($section->getID() === 'additional' && count(\OC_App::getForms('admin')) > 0)) {
Please login to merge, or discard this patch.
settings/Controller/AdminSettingsController.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -84,7 +84,7 @@  discard block
 block discarded – undo
84 84
 		);
85 85
 		$formatted = $this->formatSettings($settings);
86 86
 		// Do not show legacy forms for sub admins
87
-		if($section === 'additional' && !$isSubAdmin) {
87
+		if ($section === 'additional' && !$isSubAdmin) {
88 88
 			$formatted['content'] .= $this->getLegacyForms();
89 89
 		}
90 90
 		return $formatted;
@@ -96,9 +96,9 @@  discard block
 block discarded – undo
96 96
 	private function getLegacyForms() {
97 97
 		$forms = \OC_App::getForms('admin');
98 98
 
99
-		$forms = array_map(function ($form) {
99
+		$forms = array_map(function($form) {
100 100
 			if (preg_match('%(<h2(?P<class>[^>]*)>.*?</h2>)%i', $form, $regs)) {
101
-				$sectionName = str_replace('<h2' . $regs['class'] . '>', '', $regs[0]);
101
+				$sectionName = str_replace('<h2'.$regs['class'].'>', '', $regs[0]);
102 102
 				$sectionName = str_replace('</h2>', '', $sectionName);
103 103
 				$anchor = strtolower($sectionName);
104 104
 				$anchor = str_replace(' ', '-', $anchor);
Please login to merge, or discard this patch.