sabre-io / dav

sabre/dav is a CalDAV, CardDAV and WebDAV framework for PHP
http://sabre.io
BSD 3-Clause "New" or "Revised" License
1.51k stars 345 forks source link

Spurious DOMExceptions / "Namespace Error" #95

Closed evert closed 11 years ago

evert commented 11 years ago

Original author: toupeir...@gmail.com (July 14, 2009 15:46:49)

Hi Evert,

On our website MyDrive.ch we sometimes have DOMException errors on PROPFIND requests in our logs. I don't know yet which clients are causing this because none of our users have complained about it so far...

Here's a partial backtrace for a PROPFIND request to "/Foto-Gallerie/Mika%5fHolger%5fMeuselwitz/14-07-2009-2/Gasthof%20Waltersdorf.JPG" (only the SabreDAV part):

DOMException: Namespace Error in /var/www/mydrive/vendor/sabredav/lib/Sabre/DAV/Server.php at line 1358

0 /var/www/mydrive/vendor/sabredav/lib/Sabre/DAV/Server.php(1358):

DOMDocument->createElementNS('', 'x1:')

1 /var/www/mydrive/vendor/sabredav/lib/Sabre/DAV/Server.php(1239):

Sabre_DAV_Server->writeProperties(Object(DOMElement), '/Foto-Gallerie/...', Array, Array)

2 /var/www/mydrive/vendor/sabredav/lib/Sabre/DAV/Server.php(418):

Sabre_DAV_Server->generatePropfindResponse(Array, Array)

3 [internal function]: Sabre_DAV_Server->httpPropfind()

4 /var/www/mydrive/vendor/sabredav/lib/Sabre/DAV/Server.php(758):

call_user_func(Array)

The problem seems to be that the namespace passed to createElementNS() is empty? Any idea what could be causing this, or how to work around it?

We were using 0.7 until now, I just saw that 0.8 was available and after some quick tests upgraded to it. The relevant section in DAV/Server.php doesn't seem to have changed, so the problem is probably still there.

Original issue: http://code.google.com/p/sabredav/issues/detail?id=8

evert commented 11 years ago

From evert...@gmail.com on July 14, 2009 16:13:50: Hi Toupeira,

Would you be able to supply the complete request body + headers for this?

It looks like a client is trying to make a propfind request with a property unknown to SabreDAV (in a custom namespace).

I'm interested to see what this request is exactly..

Thanks!

evert commented 11 years ago

From toupeir...@gmail.com on July 14, 2009 17:23:17: I'll try to capture it, but it will be difficult because I don't know who's doing it ;)

evert commented 11 years ago

From evert...@gmail.com on July 14, 2009 17:27:49: Perhaps I can find stuff just based on looking at the actual code.

evert commented 11 years ago

From toupeir...@gmail.com on July 14, 2009 19:07:43: Hold on, I changed the code so it now simply catches that exception, logs the request body (using $this->httpRequest->getBody(true)) and headers ($_SERVER), and re-throws the exception. Now I'll just have to wait... it seems it doesn't happen as often as I first thought ;)

evert commented 11 years ago

From evert...@gmail.com on July 14, 2009 19:21:27: Great! Even edge cases are very important for me :) I'm definitely aiming for a utopian bug-free app :)

evert commented 11 years ago

From toupeir...@gmail.com on July 16, 2009 11:06:12: The error didn't show up anymore, with 0.7 it came a dozen times a day so I suppose you already fixed the bug in 0.8 ;)

Looking at the diff between 0.7 and 0.8 I found this change in Sabre_DAV_Server#parseProps():

/* If there are no elements in here, we actually get 1 text node, this special case is dedicated to netdrive */ if ($propNodeData->nodeType != XML_ELEMENT_NODE) continue;

So it seems NetDrive caused the DOMExceptions, and this code removes the offending nodes?

evert commented 11 years ago

From evert...@gmail.com on July 16, 2009 12:47:29: Yes, I forgot about this bugfix. Netdrive sends a weird PROPFIND request, so we needed to have a special clause to get around this.

Closing this bug