Item14214: WebDAVContrib: fails to serve a topic containing characters that don't map to latin1 on Foswiki-2
Priority: Normal
Current State: Confirmed
Released In: n/a
Target Release: n/a
I have a topic that contains a typographic (long) dash. The store was converted to UTF-8 with the upgrade to Foswiki 2. When requesting that topic.txt via WebDAV, Foswiki dies on me logging the following error:
Error: HTTP::Message content must be bytes at /path/to/lib/HTTP/WebDAV.pm line 2112
This is caused by a failing call to
utf8::downgrade
at the top of HTTP::Message.
I've been looking into calling
utf8::encode
in lib/Foswiki/Plugins/FilesysVirtualPlugin/Views/txt.pm (which doesn't work nicely because the content-type has to be changed as well) or fiddling with not setting
no_conversion
in lib/HTTP/WebDAV.pm's sub GET. My latest thinking is that it's best to not worry about the kind of "file" served and simply make sure not to pass an unencoded Unicode string to HTTP::Message / into the Foswiki response:
--- a/lib/HTTP/WebDAV.pm
+++ b/lib/HTTP/WebDAV.pm
@@ -2096,7 +2096,7 @@ sub _emitBody {
}
# no_conversion is used to force
- unless ( $options{no_conversion} ) {
+ unless ( $options{no_conversion} && !utf8::is_utf8($string) ) {
# Convert perl strings to UTF-8 bytes.
utf8::encode($string);
Does that make sense?
--
FlorianSchlichting - 08 Nov 2016
Perhaps better use a positive logic?
- unless ( $options{no_conversion} ) {
+ if ( utf8::is_utf8($string) ) {
--
FlorianSchlichting - 08 Nov 2016
Setting to confirmed to take it out of the "New" uncatagorized backlog.
--
GeorgeClark - 02 Dec 2016