cross
New Foswiki release 2.1.6 is available with important security fixes.
Sourceforge foswiki email lists being discontinued. Subscribe to the new Foswiki announce and discuss lists at MailingLists
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

pencil
Priority: Normal
Current State: Confirmed
Released In: n/a
Target Release: n/a
Applies To: Extension
Component: WebDAVContrib
Branches:
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/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
 

ItemTemplate edit

Summary WebDAVContrib: fails to serve a topic containing characters that don't map to latin1 on Foswiki-2
ReportedBy FlorianSchlichting
Codebase
SVN Range
AppliesTo Extension
Component WebDAVContrib
Priority Normal
CurrentState Confirmed
WaitingFor
Checkins
TargetRelease n/a
ReleasedIn n/a
CheckinsOnBranches
trunkCheckins
masterCheckins
ItemBranchCheckins
Release02x01Checkins
Release02x00Checkins
Release01x01Checkins
Topic revision: r2 - 02 Dec 2016, GeorgeClark - This page was cached on 16 Aug 2018 - 17:43.

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