Completed
Pull Request — master (#3838)
by Vars
12:18
created
apps/dav/lib/Connector/Sabre/Auth.php 1 patch
Spacing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -170,12 +170,12 @@  discard block
 block discarded – undo
170 170
 	 */
171 171
 	private function requiresCSRFCheck() {
172 172
 		// GET requires no check at all
173
-		if($this->request->getMethod() === 'GET') {
173
+		if ($this->request->getMethod() === 'GET') {
174 174
 			return false;
175 175
 		}
176 176
 
177 177
 		// Official ownCloud clients require no checks
178
-		if($this->request->isUserAgent([
178
+		if ($this->request->isUserAgent([
179 179
 			IRequest::USER_AGENT_CLIENT_DESKTOP,
180 180
 			IRequest::USER_AGENT_CLIENT_ANDROID,
181 181
 			IRequest::USER_AGENT_CLIENT_IOS,
@@ -184,17 +184,17 @@  discard block
 block discarded – undo
184 184
 		}
185 185
 
186 186
 		// If not logged-in no check is required
187
-		if(!$this->userSession->isLoggedIn()) {
187
+		if (!$this->userSession->isLoggedIn()) {
188 188
 			return false;
189 189
 		}
190 190
 
191 191
 		// POST always requires a check
192
-		if($this->request->getMethod() === 'POST') {
192
+		if ($this->request->getMethod() === 'POST') {
193 193
 			return true;
194 194
 		}
195 195
 
196 196
 		// If logged-in AND DAV authenticated no check is required
197
-		if($this->userSession->isLoggedIn() &&
197
+		if ($this->userSession->isLoggedIn() &&
198 198
 			$this->isDavAuthenticated($this->userSession->getUser()->getUID())) {
199 199
 			return false;
200 200
 		}
@@ -210,10 +210,10 @@  discard block
 block discarded – undo
210 210
 	 */
211 211
 	private function auth(RequestInterface $request, ResponseInterface $response) {
212 212
 		$forcedLogout = false;
213
-		if(!$this->request->passesCSRFCheck() &&
213
+		if (!$this->request->passesCSRFCheck() &&
214 214
 			$this->requiresCSRFCheck()) {
215 215
 			// In case of a fail with POST we need to recheck the credentials
216
-			if($this->request->getMethod() === 'POST') {
216
+			if ($this->request->getMethod() === 'POST') {
217 217
 				$forcedLogout = true;
218 218
 			} else {
219 219
 				$response->setStatus(401);
@@ -221,10 +221,10 @@  discard block
 block discarded – undo
221 221
 			}
222 222
 		}
223 223
 
224
-		if($forcedLogout) {
224
+		if ($forcedLogout) {
225 225
 			$this->userSession->logout();
226 226
 		} else {
227
-			if($this->twoFactorManager->needsSecondFactor($this->userSession->getUser())) {
227
+			if ($this->twoFactorManager->needsSecondFactor($this->userSession->getUser())) {
228 228
 				throw new \Sabre\DAV\Exception\NotAuthenticated('2FA challenge not passed.');
229 229
 			}
230 230
 			if (\OC_User::handleApacheAuth() ||
@@ -237,19 +237,19 @@  discard block
 block discarded – undo
237 237
 				\OC_Util::setupFS($user);
238 238
 				$this->currentUser = $user;
239 239
 				$this->session->close();
240
-				return [true, $this->principalPrefix . $user];
240
+				return [true, $this->principalPrefix.$user];
241 241
 			}
242 242
 		}
243 243
 
244 244
 		if (!$this->userSession->isLoggedIn() && in_array('XMLHttpRequest', explode(',', $request->getHeader('X-Requested-With')))) {
245 245
 			// do not re-authenticate over ajax, use dummy auth name to prevent browser popup
246
-			$response->addHeader('WWW-Authenticate','DummyBasic realm="' . $this->realm . '"');
246
+			$response->addHeader('WWW-Authenticate', 'DummyBasic realm="'.$this->realm.'"');
247 247
 			$response->setStatus(401);
248 248
 			throw new \Sabre\DAV\Exception\NotAuthenticated('Cannot authenticate over ajax calls');
249 249
 		}
250 250
 
251 251
 		$data = parent::check($request, $response);
252
-		if($data[0] === true) {
252
+		if ($data[0] === true) {
253 253
 			$startPos = strrpos($data[1], '/') + 1;
254 254
 			$user = $this->userSession->getUser()->getUID();
255 255
 			$data[1] = substr_replace($data[1], $user, $startPos);
Please login to merge, or discard this patch.
apps/dav/lib/Connector/Sabre/DummyGetResponsePlugin.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -57,9 +57,9 @@
 block discarded – undo
57 57
 	 * @return false
58 58
 	 */
59 59
 	function httpGet(RequestInterface $request, ResponseInterface $response) {
60
-		$string = 'This is the WebDAV interface. It can only be accessed by ' .
60
+		$string = 'This is the WebDAV interface. It can only be accessed by '.
61 61
 			'WebDAV clients such as the ownCloud desktop sync client.';
62
-		$stream = fopen('php://memory','r+');
62
+		$stream = fopen('php://memory', 'r+');
63 63
 		fwrite($stream, $string);
64 64
 		rewind($stream);
65 65
 
Please login to merge, or discard this patch.
apps/dav/lib/Connector/Sabre/ObjectTree.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -90,7 +90,7 @@  discard block
 block discarded – undo
90 90
 			if (isset($info['transferid'])) {
91 91
 				// getNodePath is called for multiple nodes within a chunk
92 92
 				// upload call
93
-				$path = $dir . '/' . $info['name'];
93
+				$path = $dir.'/'.$info['name'];
94 94
 				$path = ltrim($path, '/');
95 95
 			}
96 96
 		}
@@ -161,7 +161,7 @@  discard block
 block discarded – undo
161 161
 			} catch (StorageNotAvailableException $e) {
162 162
 				throw new \Sabre\DAV\Exception\ServiceUnavailable('Storage is temporarily not available');
163 163
 			} catch (StorageInvalidException $e) {
164
-				throw new \Sabre\DAV\Exception\NotFound('Storage ' . $path . ' is invalid');
164
+				throw new \Sabre\DAV\Exception\NotFound('Storage '.$path.' is invalid');
165 165
 			} catch (LockedException $e) {
166 166
 				throw new \Sabre\DAV\Exception\Locked();
167 167
 			} catch (ForbiddenException $e) {
@@ -170,7 +170,7 @@  discard block
 block discarded – undo
170 170
 		}
171 171
 
172 172
 		if (!$info) {
173
-			throw new \Sabre\DAV\Exception\NotFound('File with name ' . $path . ' could not be located');
173
+			throw new \Sabre\DAV\Exception\NotFound('File with name '.$path.' could not be located');
174 174
 		}
175 175
 
176 176
 		if ($info->getType() === 'dir') {
@@ -214,7 +214,7 @@  discard block
 block discarded – undo
214 214
 			} else {
215 215
 				$destinationPermission = $infoDestination && $infoDestination->isCreatable();
216 216
 			}
217
-			$sourcePermission =  $infoSource && $infoSource->isDeletable();
217
+			$sourcePermission = $infoSource && $infoSource->isDeletable();
218 218
 		}
219 219
 
220 220
 		if (!$destinationPermission || !$sourcePermission) {
@@ -224,7 +224,7 @@  discard block
 block discarded – undo
224 224
 		$targetNodeExists = $this->nodeExists($destinationPath);
225 225
 		$sourceNode = $this->getNodeForPath($sourcePath);
226 226
 		if ($sourceNode instanceof \Sabre\DAV\ICollection && $targetNodeExists) {
227
-			throw new \Sabre\DAV\Exception\Forbidden('Could not copy directory ' . $sourceNode->getName() . ', target exists');
227
+			throw new \Sabre\DAV\Exception\Forbidden('Could not copy directory '.$sourceNode->getName().', target exists');
228 228
 		}
229 229
 		list($sourceDir,) = \Sabre\HTTP\URLUtil::splitPath($sourcePath);
230 230
 		list($destinationDir,) = \Sabre\HTTP\URLUtil::splitPath($destinationPath);
Please login to merge, or discard this patch.
apps/dav/lib/Connector/Sabre/TagsPlugin.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -220,9 +220,9 @@  discard block
 block discarded – undo
220 220
 		)) {
221 221
 			// note: pre-fetching only supported for depth <= 1
222 222
 			$folderContent = $node->getChildren();
223
-			$fileIds[] = (int)$node->getId();
223
+			$fileIds[] = (int) $node->getId();
224 224
 			foreach ($folderContent as $info) {
225
-				$fileIds[] = (int)$info->getId();
225
+				$fileIds[] = (int) $info->getId();
226 226
 			}
227 227
 			$tags = $this->getTagger()->getTagsForObjects($fileIds);
228 228
 			if ($tags === false) {
@@ -281,7 +281,7 @@  discard block
 block discarded – undo
281 281
 			if (is_null($node)) {
282 282
 				return 404;
283 283
 			}
284
-			if ((int)$favState === 1 || $favState === 'true') {
284
+			if ((int) $favState === 1 || $favState === 'true') {
285 285
 				$this->getTagger()->tagAs($node->getId(), self::TAG_FAVORITE);
286 286
 			} else {
287 287
 				$this->getTagger()->unTag($node->getId(), self::TAG_FAVORITE);
Please login to merge, or discard this patch.
apps/dav/lib/Connector/Sabre/FilesReportPlugin.php 1 patch
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -172,14 +172,14 @@  discard block
 block discarded – undo
172 172
 			return;
173 173
 		}
174 174
 
175
-		$ns = '{' . $this::NS_OWNCLOUD . '}';
175
+		$ns = '{'.$this::NS_OWNCLOUD.'}';
176 176
 		$requestedProps = [];
177 177
 		$filterRules = [];
178 178
 
179 179
 		// parse report properties and gather filter info
180 180
 		foreach ($report as $reportProps) {
181 181
 			$name = $reportProps['name'];
182
-			if ($name === $ns . 'filter-rules') {
182
+			if ($name === $ns.'filter-rules') {
183 183
 				$filterRules = $reportProps['value'];
184 184
 			} else if ($name === '{DAV:}prop') {
185 185
 				// propfind properties
@@ -240,7 +240,7 @@  discard block
 block discarded – undo
240 240
 		if (empty($filesUri)) {
241 241
 			return '';
242 242
 		}
243
-		return '/' . $filesUri;
243
+		return '/'.$filesUri;
244 244
 	}
245 245
 
246 246
 	/**
@@ -252,15 +252,15 @@  discard block
 block discarded – undo
252 252
 	 * @throws TagNotFoundException whenever a tag was not found
253 253
 	 */
254 254
 	protected function processFilterRules($filterRules) {
255
-		$ns = '{' . $this::NS_OWNCLOUD . '}';
255
+		$ns = '{'.$this::NS_OWNCLOUD.'}';
256 256
 		$resultFileIds = null;
257 257
 		$systemTagIds = [];
258 258
 		$favoriteFilter = null;
259 259
 		foreach ($filterRules as $filterRule) {
260
-			if ($filterRule['name'] === $ns . 'systemtag') {
260
+			if ($filterRule['name'] === $ns.'systemtag') {
261 261
 				$systemTagIds[] = $filterRule['value'];
262 262
 			}
263
-			if ($filterRule['name'] === $ns . 'favorite') {
263
+			if ($filterRule['name'] === $ns.'favorite') {
264 264
 				$favoriteFilter = true;
265 265
 			}
266 266
 		}
@@ -299,7 +299,7 @@  discard block
 block discarded – undo
299 299
 			}
300 300
 
301 301
 			if (!empty($unknownTagIds)) {
302
-				throw new TagNotFoundException('Tag with ids ' . implode(', ', $unknownTagIds) . ' not found');
302
+				throw new TagNotFoundException('Tag with ids '.implode(', ', $unknownTagIds).' not found');
303 303
 			}
304 304
 		}
305 305
 
@@ -339,7 +339,7 @@  discard block
 block discarded – undo
339 339
 	public function prepareResponses($filesUri, $requestedProps, $nodes) {
340 340
 		$responses = [];
341 341
 		foreach ($nodes as $node) {
342
-			$propFind = new PropFind($filesUri . $node->getPath(), $requestedProps);
342
+			$propFind = new PropFind($filesUri.$node->getPath(), $requestedProps);
343 343
 
344 344
 			$this->server->getPropertiesByNode($propFind, $node);
345 345
 			// copied from Sabre Server's getPropertiesForPath
@@ -352,7 +352,7 @@  discard block
 block discarded – undo
352 352
 			}
353 353
 
354 354
 			$responses[] = new Response(
355
-				rtrim($this->server->getBaseUri(), '/') . $filesUri . $node->getPath(),
355
+				rtrim($this->server->getBaseUri(), '/').$filesUri.$node->getPath(),
356 356
 				$result,
357 357
 				200
358 358
 			);
Please login to merge, or discard this patch.
apps/dav/lib/Connector/Sabre/ChecksumList.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -66,7 +66,7 @@
 block discarded – undo
66 66
 	function xmlSerialize(Writer $writer) {
67 67
 
68 68
 		foreach ($this->checksums as $checksum) {
69
-			$writer->writeElement('{' . self::NS_OWNCLOUD . '}checksum', $checksum);
69
+			$writer->writeElement('{'.self::NS_OWNCLOUD.'}checksum', $checksum);
70 70
 		}
71 71
 	}
72 72
 }
Please login to merge, or discard this patch.
apps/dav/lib/Connector/Sabre/Directory.php 1 patch
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -115,7 +115,7 @@  discard block
 block discarded – undo
115 115
 				// exit if we can't create a new file and we don't updatable existing file
116 116
 				$info = \OC_FileChunking::decodeName($name);
117 117
 				if (!$this->fileView->isCreatable($this->path) &&
118
-					!$this->fileView->isUpdatable($this->path . '/' . $info['name'])
118
+					!$this->fileView->isUpdatable($this->path.'/'.$info['name'])
119 119
 				) {
120 120
 					throw new \Sabre\DAV\Exception\Forbidden();
121 121
 				}
@@ -129,7 +129,7 @@  discard block
 block discarded – undo
129 129
 
130 130
 			$this->fileView->verifyPath($this->path, $name);
131 131
 
132
-			$path = $this->fileView->getAbsolutePath($this->path) . '/' . $name;
132
+			$path = $this->fileView->getAbsolutePath($this->path).'/'.$name;
133 133
 			// using a dummy FileInfo is acceptable here since it will be refreshed after the put is complete
134 134
 			$info = new \OC\Files\FileInfo($path, null, null, array(), null);
135 135
 			$node = new \OCA\DAV\Connector\Sabre\File($this->fileView, $info);
@@ -162,9 +162,9 @@  discard block
 block discarded – undo
162 162
 			}
163 163
 
164 164
 			$this->fileView->verifyPath($this->path, $name);
165
-			$newPath = $this->path . '/' . $name;
165
+			$newPath = $this->path.'/'.$name;
166 166
 			if (!$this->fileView->mkdir($newPath)) {
167
-				throw new \Sabre\DAV\Exception\Forbidden('Could not create directory ' . $newPath);
167
+				throw new \Sabre\DAV\Exception\Forbidden('Could not create directory '.$newPath);
168 168
 			}
169 169
 		} catch (\OCP\Files\StorageNotAvailableException $e) {
170 170
 			throw new \Sabre\DAV\Exception\ServiceUnavailable($e->getMessage());
@@ -188,7 +188,7 @@  discard block
 block discarded – undo
188 188
 	 * @throws \Sabre\DAV\Exception\ServiceUnavailable
189 189
 	 */
190 190
 	public function getChild($name, $info = null) {
191
-		$path = $this->path . '/' . $name;
191
+		$path = $this->path.'/'.$name;
192 192
 		if (is_null($info)) {
193 193
 			try {
194 194
 				$this->fileView->verifyPath($this->path, $name);
@@ -203,7 +203,7 @@  discard block
 block discarded – undo
203 203
 		}
204 204
 
205 205
 		if (!$info) {
206
-			throw new \Sabre\DAV\Exception\NotFound('File with name ' . $path . ' could not be located');
206
+			throw new \Sabre\DAV\Exception\NotFound('File with name '.$path.' could not be located');
207 207
 		}
208 208
 
209 209
 		if ($info['mimetype'] == 'httpd/unix-directory') {
@@ -255,7 +255,7 @@  discard block
 block discarded – undo
255 255
 		// (required old code) instead of "updateFile".
256 256
 		//
257 257
 		// TODO: resolve chunk file name here and implement "updateFile"
258
-		$path = $this->path . '/' . $name;
258
+		$path = $this->path.'/'.$name;
259 259
 		return $this->fileView->file_exists($path);
260 260
 
261 261
 	}
Please login to merge, or discard this patch.
apps/dav/lib/Connector/Sabre/BlockLegacyClientPlugin.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -64,7 +64,7 @@  discard block
 block discarded – undo
64 64
 	 */
65 65
 	public function beforeHandler(RequestInterface $request) {
66 66
 		$userAgent = $request->getHeader('User-Agent');
67
-		if($userAgent === null) {
67
+		if ($userAgent === null) {
68 68
 			return;
69 69
 		}
70 70
 
@@ -73,7 +73,7 @@  discard block
 block discarded – undo
73 73
 		// Match on the mirall version which is in scheme "Mozilla/5.0 (%1) mirall/%2" or
74 74
 		// "mirall/%1" for older releases
75 75
 		preg_match("/(?:mirall\\/)([\d.]+)/i", $userAgent, $versionMatches);
76
-		if(isset($versionMatches[1]) &&
76
+		if (isset($versionMatches[1]) &&
77 77
 			version_compare($versionMatches[1], $minimumSupportedDesktopVersion) === -1) {
78 78
 			throw new \Sabre\DAV\Exception\Forbidden('Unsupported client version.');
79 79
 		}
Please login to merge, or discard this patch.
apps/dav/lib/Connector/Sabre/CommentPropertiesPlugin.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -99,13 +99,13 @@  discard block
 block discarded – undo
99 99
 	 * @return mixed|string
100 100
 	 */
101 101
 	public function getCommentsLink(Node $node) {
102
-		$href =  $this->server->getBaseUri();
102
+		$href = $this->server->getBaseUri();
103 103
 		$entryPoint = strpos($href, '/remote.php/');
104
-		if($entryPoint === false) {
104
+		if ($entryPoint === false) {
105 105
 			// in case we end up somewhere else, unexpectedly.
106 106
 			return null;
107 107
 		}
108
-		$commentsPart = 'dav/comments/files/' . rawurldecode($node->getId());
108
+		$commentsPart = 'dav/comments/files/'.rawurldecode($node->getId());
109 109
 		$href = substr_replace($href, $commentsPart, $entryPoint + strlen('/remote.php/'));
110 110
 		return $href;
111 111
 	}
@@ -119,7 +119,7 @@  discard block
 block discarded – undo
119 119
 	 */
120 120
 	public function getUnreadCount(Node $node) {
121 121
 		$user = $this->userSession->getUser();
122
-		if(is_null($user)) {
122
+		if (is_null($user)) {
123 123
 			return null;
124 124
 		}
125 125
 
Please login to merge, or discard this patch.