Skip Menu |

This queue is for tickets about the Net-DAV-Server CPAN distribution.

Report information
The Basics
Id: 20001
Status: open
Priority: 0/
Queue: Net-DAV-Server

People
Owner: BRONG [...] cpan.org
Requestors: hachi [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: 1.28
Fixed in: (no value)



Subject: Character set interpretation broken
The code in Net::DAV::Server performs a conversion to make all calls to Filesys::Virtual::* manipulate filenames as octet strings and not UTF-8. Since all the DAV clients I have tested (Windows Explorer, OSX Finder, DAVExplorer) appear to want URI encoded UTF-8 data, and perl's internal data format is UTF-8, I have found the encode_utf8 and decode_utf8 calls in the code to be completely unwanted.
Subject: nds.patch
=== local/Net-DAV-Server/lib/Net/DAV/Server.pm ================================================================== --- local/Net-DAV-Server/lib/Net/DAV/Server.pm (revision 3998) +++ local/Net-DAV-Server/lib/Net/DAV/Server.pm (local) @@ -2,7 +2,6 @@ use strict; use warnings; use File::Slurp; -use Encode; use File::Find::Rule::Filesys::Virtual; use HTTP::Date qw(time2str time2isoz); use HTTP::Headers; @@ -45,7 +44,7 @@ my $fs = $self->filesys || die 'Boom'; my $method = $request->method; - my $path = decode_utf8 uri_unescape $request->uri->path; + my $path = uri_unescape $request->uri->path; if (!defined $response) { $response = HTTP::Response->new; @@ -80,7 +79,7 @@ sub head { my ($self, $request, $response) = @_; - my $path = decode_utf8 uri_unescape $request->uri->path; + my $path = uri_unescape $request->uri->path; my $fs = $self->filesys; if ($fs->test("f", $path) && $fs->test("r", $path)) { @@ -100,7 +99,7 @@ sub get { my ($self, $request, $response) = @_; - my $path = decode_utf8 uri_unescape $request->uri->path; + my $path = uri_unescape $request->uri->path; my $fs = $self->filesys; if ($fs->test('f', $path) && $fs->test('r', $path)) { @@ -133,7 +132,7 @@ sub put { my ($self, $request, $response) = @_; - my $path = decode_utf8 uri_unescape $request->uri->path; + my $path = uri_unescape $request->uri->path; my $fs = $self->filesys; $response = HTTP::Response->new(201, "CREATED", $response->headers); @@ -156,7 +155,7 @@ sub delete { my ($self, $request, $response) = @_; - my $path = decode_utf8 uri_unescape $request->uri->path; + my $path = uri_unescape $request->uri->path; my $fs = $self->filesys; if ($request->uri->fragment) { @@ -204,7 +203,7 @@ sub copy { my ($self, $request, $response) = @_; - my $path = decode_utf8 uri_unescape $request->uri->path; + my $path = uri_unescape $request->uri->path; my $fs = $self->filesys; my $destination = $request->header('Destination'); @@ -266,7 +265,7 @@ sub copy_file { my ($self, $request, $response) = @_; - my $path = decode_utf8 uri_unescape $request->uri->path; + my $path = uri_unescape $request->uri->path; my $fs = $self->filesys; my $destination = $request->header('Destination'); @@ -325,7 +324,7 @@ sub lock { my ($self, $request, $response) = @_; - my $path = decode_utf8 uri_unescape $request->uri->path; + my $path = uri_unescape $request->uri->path; my $fs = $self->filesys; $fs->lock($path); @@ -335,7 +334,7 @@ sub unlock { my ($self, $request, $response) = @_; - my $path = decode_utf8 uri_unescape $request->uri->path; + my $path = uri_unescape $request->uri->path; my $fs = $self->filesys; $fs->unlock($path); @@ -345,7 +344,7 @@ sub mkcol { my ($self, $request, $response) = @_; - my $path = decode_utf8 uri_unescape $request->uri->path; + my $path = uri_unescape $request->uri->path; my $fs = $self->filesys; if ($request->content) { @@ -367,7 +366,7 @@ sub propfind { my ($self, $request, $response) = @_; - my $path = decode_utf8 uri_unescape $request->uri->path; + my $path = uri_unescape $request->uri->path; my $fs = $self->filesys; my $depth = $request->header('Depth'); @@ -444,7 +443,7 @@ my $href = $doc->createElement('D:href'); $href->appendText( File::Spec->catdir( - map { uri_escape encode_utf8 $_} File::Spec->splitdir($path) + map { uri_escape $_} File::Spec->splitdir($path) ) ); $resp->addChild($href);
On Tue Jun 20 05:30:04 2006, HACHI wrote: Show quoted text
> The code in Net::DAV::Server performs a conversion to make all calls
to Show quoted text
> Filesys::Virtual::* manipulate filenames as octet strings and not
UTF-8. Show quoted text
> > Since all the DAV clients I have tested (Windows Explorer, OSX
Finder, Show quoted text
> DAVExplorer) appear to want URI encoded UTF-8 data, and perl's
internal Show quoted text
> data format is UTF-8, I have found the encode_utf8 and decode_utf8
calls Show quoted text
> in the code to be completely unwanted.
Thanks for this, and your other patch as well. I've been meaning for a while to spend some time on Net::DAV::Server, and your patches will certainly be considered and either merged as is or re-written to match the changes I want to make. I'm afraid I branched rather a long way from Net::DAV::Server for my implementation of Apache mod_perl compatibility, so I'll need to integrate that back too! Thanks again, Bron.
On Tue Jun 20 05:30:04 2006, HACHI wrote: Show quoted text
> The code in Net::DAV::Server performs a conversion to make all calls
to Show quoted text
> Filesys::Virtual::* manipulate filenames as octet strings and not
UTF-8. Show quoted text
> > Since all the DAV clients I have tested (Windows Explorer, OSX
Finder, Show quoted text
> DAVExplorer) appear to want URI encoded UTF-8 data, and perl's
internal Show quoted text
> data format is UTF-8, I have found the encode_utf8 and decode_utf8
calls Show quoted text
> in the code to be completely unwanted.
Sorry - on further examination I really don't see what problem you're trying to solve here. The decode_utf8 and encode_utf8 calls do server a purpose, and I suspect you're reading them backwards. The 'decode_utf8' on incoming connections converts octet strings into "characters" within Perl, and the the 'encode_utf8' on the way back converts them back into octet strings for URI encoding and returning to the client. While there is no standard (very unfortunately) about this behaviour, it seems to be what most of the sane clients have chosen to do. There is some small performance hit for doing things this way with Encode, but the advantage is that you are working with proper Perl Unicode strings inside the Perl code. I suspect the bug you're trying to solve is actually that some clients _DON'T_ work this way - they just send raw octets in their own native charset. If you work in octets all the way through in Perl then it "just works"[tm], but only because it's returning the same broken values without testing them for UTF8 correctness. So I won't include this patch in 1.29, but I'd be very interested in talking with you about the underlying problems you experienced and coming up with another solution to them. Regards, Bron.