You are here: Foswiki>Tasks Web>Item14214 (02 Dec 2016, GeorgeClark)Edit Attach

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
Applies To: Extension
Component: WebDAVContrib
Reported By: FlorianSchlichting
Waiting For:
Last Change By: GeorgeClark
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/ 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/ (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/'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/
+++ b/lib/HTTP/
@@ -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.

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

ItemTemplate edit

Summary WebDAVContrib: fails to serve a topic containing characters that don't map to latin1 on Foswiki-2
ReportedBy FlorianSchlichting
SVN Range
AppliesTo Extension
Component WebDAVContrib
Priority Normal
CurrentState Confirmed
TargetRelease n/a
ReleasedIn n/a
Topic revision: r2 - 02 Dec 2016, GeorgeClark
The copyright of the content on this website is held by the contributing authors, except where stated elsewhere. See Copyright Statement. Creative Commons License    Legal Imprint    Privacy Policy