android-library icon indicating copy to clipboard operation
android-library copied to clipboard

[BUG] App is crashing if WebDAV server returns non-empty "getcontenttype" for a collection

Open bohwaz opened this issue 1 year ago • 2 comments

Actual behaviour

Change WebDAV server to return a string for "getcontenttype" for a directory (collection) in the "200 OK" propstat for the resource, item of "getcontenttype" being in the "404 Not Found" propstat.

Refresh the file listing in the app. It crashes and cannot be restarted.

This works:

	<d:response>
		<d:href>/remote.php/webdav/Photos/</d:href>
		<d:propstat>
			<d:prop>
				<d:resourcetype>
					<d:collection/>
				</d:resourcetype>
				<d:getlastmodified>Mon, 03 Oct 2022 01:42:33 GMT</d:getlastmodified>
				<d:getetag>&quot;633a3e099376c&quot;</d:getetag>
				<d:quota-used-bytes>1011464</d:quota-used-bytes>
				<d:quota-available-bytes>-3</d:quota-available-bytes>
				<oc:permissions>RDNVCK</oc:permissions>
				<oc:id>00000013ocaveki6uxj5</oc:id>
				<oc:size>1011464</oc:size>
				<oc:privatelink>http://localhost:8082/index.php/f/13</oc:privatelink>
				<oc:share-types/>
			</d:prop>
			<d:status>HTTP/1.1 200 OK</d:status>
		</d:propstat>
		<d:propstat>
			<d:prop>
				<d:displayname/>
				<d:getcontenttype/>
				<d:getcontentlength/>
				<d:creationdate/>
			</d:prop>
			<d:status>HTTP/1.1 404 Not Found</d:status>
		</d:propstat>
	</d:response>

This makes the app crash:

	<d:response>
		<d:href>/remote.php/webdav/Photos/</d:href>
		<d:propstat>
			<d:prop>
				<d:resourcetype>
					<d:collection/>
				</d:resourcetype>
				<d:getlastmodified>Mon, 03 Oct 2022 01:42:33 GMT</d:getlastmodified>
				<d:getetag>&quot;633a3e099376c&quot;</d:getetag>
				<d:quota-used-bytes>1011464</d:quota-used-bytes>
				<d:quota-available-bytes>-3</d:quota-available-bytes>
				<oc:permissions>RDNVCK</oc:permissions>
				<oc:id>00000013ocaveki6uxj5</oc:id>
				<oc:size>1011464</oc:size>
				<oc:privatelink>http://localhost:8082/index.php/f/13</oc:privatelink>
				<oc:share-types/>
				<d:getcontenttype>something</d:getcontenttype>
			</d:prop>
			<d:status>HTTP/1.1 200 OK</d:status>
		</d:propstat>
		<d:propstat>
			<d:prop>
				<d:displayname/>
				<d:getcontentlength/>
				<d:creationdate/>
			</d:prop>
			<d:status>HTTP/1.1 404 Not Found</d:status>
		</d:propstat>
	</d:response>

Expected behaviour

No crash :)

Generally it seems that the app is very fragile if the WebDAV server response changes, even just a bit, more checks should be done instead of failing dramatically like that.

bohwaz avatar Oct 03 '22 02:10 bohwaz

Hi @bohwaz. I agree with you, the app should not crash. But let me understand the use case to change the content type of a directory.

For a directory, we expect DIR in oC10 or httpd/unix-directory in oCIS. That's how we understand it is an actual directory. something is not a real mime type for a directory. Let us know if there is another mime type for a folder that you consider we should handle 👍

I'll transfer the issue to the android-library repository which is the one that handles all the network requests 👍

abelgardep avatar Oct 03 '22 08:10 abelgardep

Thanks for the reply :)

'something' was just to say that a random string would crash the app :)

I tested with 'directory' first, which is what is returned by mime_content_type in PHP.

file command in Linux returns 'inode/directory' for a directory.

But anyway, the app should not rely on that to know if a resource is a directory, but use 'resourcetype' with 'collection' :)

bohwaz avatar Oct 03 '22 10:10 bohwaz