Skip to content

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

Closed

Description

@GiantCrocodile

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"
}

Activity

  1. changed the title [-]Special characters in file name cause fatal exception[/-] [+]Special characters in file name cause fatal exception in webdav[/+] on Sep 20, 2017
  2. blizzz commented on Sep 25, 2017

    @blizzz
    Member

    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

  3. GiantCrocodile commented on Sep 26, 2017

    @GiantCrocodile
    Author

    @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.

  4. MorrisJobke commented on Jan 2, 2018

    @MorrisJobke
    Member
  5. MorrisJobke commented on Jan 2, 2018

    @MorrisJobke
    Member

    I could reproduce this by following the latest comment.

  6. added
    good first issueSmall tasks with clear documentation about how and in which place you need to fix things in.
    on Jan 2, 2018
  7. rullzer commented on Jan 3, 2018

    @rullzer
    Member

    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.

  8. self-assigned this
    on Jan 3, 2018
  9. MorrisJobke commented on Jan 3, 2018

    @MorrisJobke
    Member

    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"}
    
  10. MorrisJobke commented on Jan 3, 2018

    @MorrisJobke
    Member

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

  11. added this to the Nextcloud 13 milestone on Jan 3, 2018
  12. removed their assignment
    on Jan 3, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions