Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Special characters in file name cause fatal exception in webdav #6594

Closed
GiantCrocodile opened this issue Sep 20, 2017 · 7 comments
Closed
Labels
3. to review Waiting for reviews bug feature: dav feature: files feature: filesystem good first issue Small tasks with clear documentation about how and in which place you need to fix things in.
Milestone

Comments

@GiantCrocodile
Copy link

When you try to rename a file with special characters inside (like <) you get an exception in protocol:

{
   "reqId":"<removed>",
   "level":4,
   "time":"<removed>",
   "remoteAddr":"<removed>",
   "user":"<removed>",
   "app":"webdav",
   "method":"MOVE",
   "url":"\/remote.php\/webdav\/Photos\/Coast.jpg",
   "message":"Exception: {\"Exception\":\"Sabre\\\\DAV\\\\Exception\\\\Conflict\",\"Message\":\"The destination node is not found\",\"Code\":0,\"Trace\":\"#0 \\\/var\\\/www\\\/nextcloud\\\/3rdparty\\\/sabre\\\/dav\\\/lib\\\/DAV\\\/CorePlugin.php(624): Sabre\\\\DAV\\\\Server->getCopyAndMoveInfo(Object(Sabre\\\\HTTP\\\\Request))\\n#1 [internal function]: Sabre\\\\DAV\\\\CorePlugin->httpMove(Object(Sabre\\\\HTTP\\\\Request), Object(Sabre\\\\HTTP\\\\Response))\\n#2 \\\/var\\\/www\\\/nextcloud\\\/3rdparty\\\/sabre\\\/event\\\/lib\\\/EventEmitterTrait.php(105): call_user_func_array(Array, Array)\\n#3 \\\/var\\\/www\\\/nextcloud\\\/3rdparty\\\/sabre\\\/dav\\\/lib\\\/DAV\\\/Server.php(479): Sabre\\\\Event\\\\EventEmitter->emit('method:MOVE', Array)\\n#4 \\\/var\\\/www\\\/nextcloud\\\/3rdparty\\\/sabre\\\/dav\\\/lib\\\/DAV\\\/Server.php(254): Sabre\\\\DAV\\\\Server->invokeMethod(Object(Sabre\\\\HTTP\\\\Request), Object(Sabre\\\\HTTP\\\\Response))\\n#5 \\\/var\\\/www\\\/nextcloud\\\/apps\\\/dav\\\/appinfo\\\/v1\\\/webdav.php(76): Sabre\\\\DAV\\\\Server->exec()\\n#6 \\\/var\\\/www\\\/nextcloud\\\/remote.php(162): require_once('\\\/var\\\/www\\\/nextcl...')\\n#7 {main}\",\"File\":\"\\\/var\\\/www\\\/nextcloud\\\/3rdparty\\\/sabre\\\/dav\\\/lib\\\/DAV\\\/Server.php\",\"Line\":749}",
   "userAgent":"<removed>",
   "version":"12.0.3.3"
}
@GiantCrocodile GiantCrocodile changed the title Special characters in file name cause fatal exception Special characters in file name cause fatal exception in webdav Sep 20, 2017
@blizzz
Copy link
Member

blizzz commented Sep 25, 2017

Works for me™️ (i.e. cannot reproduce)

Please give a complete report using the template https://raw.github.com/nextcloud/core/master/issue_template.md

@GiantCrocodile
Copy link
Author

GiantCrocodile commented Sep 26, 2017

@blizzz Follow these steps:

  1. go into a directory, for example default one 'Videos'
  2. click on new > new folder/directory
  3. enter name <test>a</test>

You get this exception:
grafik

It seems to be related to directories, not files. My description from first post was misleading. Sorry for this!

This happens on a Linux server with Postgresql, Nginx and PHP 7.0 in fpm mode.

@MorrisJobke
Copy link
Member

cc @icewind1991 @rullzer @danxuliu

@MorrisJobke
Copy link
Member

I could reproduce this by following the latest comment.

@MorrisJobke MorrisJobke added the good first issue Small tasks with clear documentation about how and in which place you need to fix things in. label Jan 2, 2018
@rullzer
Copy link
Member

rullzer commented Jan 3, 2018

It is because of the final /

Lets take the folder foo and you want to create bar/baz. Internally this is translated to create foo/bar/baz

So we try to get the node foo/bar and create the folder baz in there. But of course foo/bar doens't exist yet.

Long story short. / should not be allowed in file/folder names as it is the default directory separator.

@MorrisJobke
Copy link
Member

MorrisJobke commented Jan 3, 2018

We should also look into the log levels, because those are basically user errors, that should not be logged in the server (at least only in debug log).

  • ❌ Creating a folder (log level 4):
{"reqId":"hXHDSNaLu9iWEEWHGb8L","level":4,"time":"2018-01-03T10:40:00+00:00","remoteAddr":"192.168.99.1","user":"admin","app":"webdav","method":"MKCOL","url":"\/server\/remote.php\/webdav\/dsfb\/dsaf","message":"Exception: {\"Exception\":\"Sabre\\\\DAV\\\\Exception\\\\Conflict\",\"Message\":\"Parent node does not exist\",\"Code\":0,\"Trace\":\"#0 \\\/srv\\\/projects\\\/server\\\/3rdparty\\\/sabre\\\/dav\\\/lib\\\/DAV\\\/CorePlugin.php(590): Sabre\\\\DAV\\\\Server->createCollection('dsfb\\\/dsaf', Object(Sabre\\\\DAV\\\\MkCol))\\n#1 [internal function]: Sabre\\\\DAV\\\\CorePlugin->httpMkcol(Object(Sabre\\\\HTTP\\\\Request), Object(Sabre\\\\HTTP\\\\Response))\\n#2 \\\/srv\\\/projects\\\/server\\\/3rdparty\\\/sabre\\\/event\\\/lib\\\/EventEmitterTrait.php(105): call_user_func_array(Array, Array)\\n#3 \\\/srv\\\/projects\\\/server\\\/3rdparty\\\/sabre\\\/dav\\\/lib\\\/DAV\\\/Server.php(479): Sabre\\\\Event\\\\EventEmitter->emit('method:MKCOL', Array)\\n#4 \\\/srv\\\/projects\\\/server\\\/3rdparty\\\/sabre\\\/dav\\\/lib\\\/DAV\\\/Server.php(254): Sabre\\\\DAV\\\\Server->invokeMethod(Object(Sabre\\\\HTTP\\\\Request), Object(Sabre\\\\HTTP\\\\Response))\\n#5 \\\/srv\\\/projects\\\/server\\\/apps\\\/dav\\\/appinfo\\\/v1\\\/webdav.php(80): Sabre\\\\DAV\\\\Server->exec()\\n#6 \\\/srv\\\/projects\\\/server\\\/remote.php(164): require_once('\\\/srv\\\/projects\\\/s...')\\n#7 {main}\",\"File\":\"\\\/srv\\\/projects\\\/server\\\/3rdparty\\\/sabre\\\/dav\\\/lib\\\/DAV\\\/Server.php\",\"Line\":1167}","userAgent":"Mozilla\/5.0 (Macintosh; Intel Mac OS X 10_13_2) AppleWebKit\/604.4.7 (KHTML, like Gecko) Version\/11.0.2 Safari\/604.4.7","version":"13.0.0.8"}
  • ✅ Creating a file (log level 0):
{"reqId":"InZ000tumdfmR0fzpp29","level":0,"time":"2018-01-03T10:41:37+00:00","remoteAddr":"192.168.99.1","user":"admin","app":"webdav","method":"PUT","url":"\/server\/remote.php\/webdav\/test\/asdf.txt","message":"Exception: {\"Exception\":\"Sabre\\\\DAV\\\\Exception\\\\NotFound\",\"Message\":\"File with name test could not be located\",\"Code\":0,\"Trace\":\"#0 \\\/srv\\\/projects\\\/server\\\/3rdparty\\\/sabre\\\/dav\\\/lib\\\/DAV\\\/Server.php(1083): OCA\\\\DAV\\\\Connector\\\\Sabre\\\\ObjectTree->getNodeForPath('test')\\n#1 \\\/srv\\\/projects\\\/server\\\/3rdparty\\\/sabre\\\/dav\\\/lib\\\/DAV\\\/CorePlugin.php(525): Sabre\\\\DAV\\\\Server->createFile('test\\\/asdf.txt', Resource id #23, NULL)\\n#2 [internal function]: Sabre\\\\DAV\\\\CorePlugin->httpPut(Object(Sabre\\\\HTTP\\\\Request), Object(Sabre\\\\HTTP\\\\Response))\\n#3 \\\/srv\\\/projects\\\/server\\\/3rdparty\\\/sabre\\\/event\\\/lib\\\/EventEmitterTrait.php(105): call_user_func_array(Array, Array)\\n#4 \\\/srv\\\/projects\\\/server\\\/3rdparty\\\/sabre\\\/dav\\\/lib\\\/DAV\\\/Server.php(479): Sabre\\\\Event\\\\EventEmitter->emit('method:PUT', Array)\\n#5 \\\/srv\\\/projects\\\/server\\\/3rdparty\\\/sabre\\\/dav\\\/lib\\\/DAV\\\/Server.php(254): Sabre\\\\DAV\\\\Server->invokeMethod(Object(Sabre\\\\HTTP\\\\Request), Object(Sabre\\\\HTTP\\\\Response))\\n#6 \\\/srv\\\/projects\\\/server\\\/apps\\\/dav\\\/appinfo\\\/v1\\\/webdav.php(80): Sabre\\\\DAV\\\\Server->exec()\\n#7 \\\/srv\\\/projects\\\/server\\\/remote.php(164): require_once('\\\/srv\\\/projects\\\/s...')\\n#8 {main}\",\"File\":\"\\\/srv\\\/projects\\\/server\\\/apps\\\/dav\\\/lib\\\/Connector\\\/Sabre\\\/ObjectTree.php\",\"Line\":174}","userAgent":"Mozilla\/5.0 (Macintosh; Intel Mac OS X 10_13_2) AppleWebKit\/604.4.7 (KHTML, like Gecko) Version\/11.0.2 Safari\/604.4.7","version":"13.0.0.8"}
  • ❌ Renaming a folder (log level 4):
{"reqId":"f6rjHArrETc2Z8O2HUVF","level":4,"time":"2018-01-03T10:47:29+00:00","remoteAddr":"192.168.99.1","user":"admin","app":"webdav","method":"MOVE","url":"\/server\/remote.php\/webdav\/CFC","message":"Exception: {\"Exception\":\"Sabre\\\\DAV\\\\Exception\\\\Conflict\",\"Message\":\"The destination may not be part of the same subtree as the source path.\",\"Code\":0,\"Trace\":\"#0 \\\/srv\\\/projects\\\/server\\\/3rdparty\\\/sabre\\\/dav\\\/lib\\\/DAV\\\/CorePlugin.php(624): Sabre\\\\DAV\\\\Server->getCopyAndMoveInfo(Object(Sabre\\\\HTTP\\\\Request))\\n#1 [internal function]: Sabre\\\\DAV\\\\CorePlugin->httpMove(Object(Sabre\\\\HTTP\\\\Request), Object(Sabre\\\\HTTP\\\\Response))\\n#2 \\\/srv\\\/projects\\\/server\\\/3rdparty\\\/sabre\\\/event\\\/lib\\\/EventEmitterTrait.php(105): call_user_func_array(Array, Array)\\n#3 \\\/srv\\\/projects\\\/server\\\/3rdparty\\\/sabre\\\/dav\\\/lib\\\/DAV\\\/Server.php(479): Sabre\\\\Event\\\\EventEmitter->emit('method:MOVE', Array)\\n#4 \\\/srv\\\/projects\\\/server\\\/3rdparty\\\/sabre\\\/dav\\\/lib\\\/DAV\\\/Server.php(254): Sabre\\\\DAV\\\\Server->invokeMethod(Object(Sabre\\\\HTTP\\\\Request), Object(Sabre\\\\HTTP\\\\Response))\\n#5 \\\/srv\\\/projects\\\/server\\\/apps\\\/dav\\\/appinfo\\\/v1\\\/webdav.php(80): Sabre\\\\DAV\\\\Server->exec()\\n#6 \\\/srv\\\/projects\\\/server\\\/remote.php(164): require_once('\\\/srv\\\/projects\\\/s...')\\n#7 {main}\",\"File\":\"\\\/srv\\\/projects\\\/server\\\/3rdparty\\\/sabre\\\/dav\\\/lib\\\/DAV\\\/Server.php\",\"Line\":772}","userAgent":"Mozilla\/5.0 (Macintosh; Intel Mac OS X 10_13_2) AppleWebKit\/604.4.7 (KHTML, like Gecko) Version\/11.0.2 Safari\/604.4.7","version":"13.0.0.8"}
  • ❌ Renaming a file (log level 4):
{"reqId":"1ZHxFTGvLuFhEM7dvvZi","level":4,"time":"2018-01-03T10:48:13+00:00","remoteAddr":"192.168.99.1","user":"admin","app":"webdav","method":"MOVE","url":"\/server\/remote.php\/webdav\/Bildschirmfoto%202017-11-30%20um%2023.09.28.png","message":"Exception: {\"Exception\":\"Sabre\\\\DAV\\\\Exception\\\\Conflict\",\"Message\":\"The destination node is not found\",\"Code\":0,\"Trace\":\"#0 \\\/srv\\\/projects\\\/server\\\/3rdparty\\\/sabre\\\/dav\\\/lib\\\/DAV\\\/CorePlugin.php(624): Sabre\\\\DAV\\\\Server->getCopyAndMoveInfo(Object(Sabre\\\\HTTP\\\\Request))\\n#1 [internal function]: Sabre\\\\DAV\\\\CorePlugin->httpMove(Object(Sabre\\\\HTTP\\\\Request), Object(Sabre\\\\HTTP\\\\Response))\\n#2 \\\/srv\\\/projects\\\/server\\\/3rdparty\\\/sabre\\\/event\\\/lib\\\/EventEmitterTrait.php(105): call_user_func_array(Array, Array)\\n#3 \\\/srv\\\/projects\\\/server\\\/3rdparty\\\/sabre\\\/dav\\\/lib\\\/DAV\\\/Server.php(479): Sabre\\\\Event\\\\EventEmitter->emit('method:MOVE', Array)\\n#4 \\\/srv\\\/projects\\\/server\\\/3rdparty\\\/sabre\\\/dav\\\/lib\\\/DAV\\\/Server.php(254): Sabre\\\\DAV\\\\Server->invokeMethod(Object(Sabre\\\\HTTP\\\\Request), Object(Sabre\\\\HTTP\\\\Response))\\n#5 \\\/srv\\\/projects\\\/server\\\/apps\\\/dav\\\/appinfo\\\/v1\\\/webdav.php(80): Sabre\\\\DAV\\\\Server->exec()\\n#6 \\\/srv\\\/projects\\\/server\\\/remote.php(164): require_once('\\\/srv\\\/projects\\\/s...')\\n#7 {main}\",\"File\":\"\\\/srv\\\/projects\\\/server\\\/3rdparty\\\/sabre\\\/dav\\\/lib\\\/DAV\\\/Server.php\",\"Line\":749}","userAgent":"Mozilla\/5.0 (Macintosh; Intel Mac OS X 10_13_2) AppleWebKit\/604.4.7 (KHTML, like Gecko) Version\/11.0.2 Safari\/604.4.7","version":"13.0.0.8"}

@MorrisJobke
Copy link
Member

The before mentioned logs are fixed in the second commit of #7676

@MorrisJobke MorrisJobke added this to the Nextcloud 13 milestone Jan 3, 2018
@MorrisJobke MorrisJobke removed their assignment Jan 3, 2018
@MorrisJobke MorrisJobke added the 3. to review Waiting for reviews label Jan 3, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
3. to review Waiting for reviews bug feature: dav feature: files feature: filesystem good first issue Small tasks with clear documentation about how and in which place you need to fix things in.
Projects
None yet
Development

No branches or pull requests

4 participants