Tags:
create new tag
, view all tags

Bug: quote in comment of file attachment is not stored properly

A quote in the comment field of a file attachment is stored 'lossy': after some views and saves the quote disappears completely.

(problem cropped up at AttachedImageDefaultAltText)

Test case

  1. add an attachment
  2. in de description field, use " or the XHTML equivalent "
  3. upload
  4. in View, look at the form field: looks like a normal quote character
  5. click on the Action link
  6. in Attach, look at the form field: looks like a normal quote character where there was "
  7. without changing, click Change properties
  8. in View again, look at the form field: looks like a normal quote character
  9. click again on Action
  10. look at the form field: the quote has disappeared completely!

First entered: (step 2 - 4)

%META:FILEATTACHMENT{name="Diagram_View.png" attr="" comment="test with one " (quote)" date="1063545116" path="Diagram_View.png" size="152592" user="guest" version="1.1"}%

This get changed to: (step 8)

%META:FILEATTACHMENT{name="Diagram_View.png" attr="" comment="test with one %_Q_% (quote)" date="1063545116" path="Diagram_View.png" size="152592" user="guest" version="1.1"}%

... and gets changed to: (step 10)

%META:FILEATTACHMENT{name="Diagram_View.png" attr="" comment="test with one " date="1063545116" path="Diagram_View.png" size="152592" user="guest" version="1.1"}%

Note that the same happens with ampersands.

The comment text is not converted from the meta data to the input field, so the input field shows the TWiki 'encoded' character (in this case the %_Q_%).

-- ArthurClemens - 14 Sep 2003

Environment

TWiki version: TWikiRelease01Feb2003
TWiki plugins: DefaultPlugin, EmptyPlugin, InterwikiPlugin
Server OS:  
Web server:  
Perl version:  
Client OS:  
Web Browser:  

-- ArthurClemens - 15 Sep 2003

Follow up

In TWiki.pm is a routine called encodeSpecialChars. Line 2149 says:

    $text =~ s/\"/"/g;

Looking at step 8, this routine must be called somewhere, although I can't find it (it is called in Form.pm and the preview script). Appearantly the quote is converted to %_Q_% but not back again.

  • No: a different routine is called: cleanValue in Meta.pm (actually written to deal with newlines, but the quote conversion has also found a place in it). But it seems that the mirror routine restoreValue is not used with writing the values to the form fields...

I found a solution that appears to work (please correct me, I write this on purpose under "Follow up") is

  1. change the attach script that it encodes the stored string (or should this be done in Meta.pm like it is now?)
  2. change the line above in TWiki.pm to: $text =~ s/\"/"/g; (added a few nops in Edit mode to see it correctly in view mode) (i.e. do away with " and replace it with "

A better solution is to let Meta call TWiki::encodeSpecialChars and TWiki::decodeSpecialChars (see meta patch Meta_handleSpecialChars.diff). The conversion back and forth works now, but a change to decodeSpecialChars is still needed:

$text =~ s/"/\"/g;
becomes
$text =~ s/"/"/g; (nop added in Edit view)

-- ArthurClemens - 15 Sep 2003

Probably the same bug as AttachCommentBadCharacters.

  • Yes, I did not know this. No solution offered there. -- AC

See also: http://www.utoronto.ca/webdocs/HTMLdocs/NewHTML/en_test.html

Fix record

Topic attachments
I Attachment History Action Size Date Who Comment
Unknown file formatdiff Meta_handleSpecialChars.diff r1 manage 0.8 K 2003-09-15 - 21:57 ArthurClemens patch to let Meta call en-decodeSpecialChars
Edit | Attach | Watch | Print version | History: r6 < r5 < r4 < r3 < r2 | Backlinks | Raw View | Raw edit | More topic actions
Topic revision: r6 - 2008-09-02 - TWikiJanitor
 
  • Learn about TWiki  
  • Download TWiki
This site is powered by the TWiki collaboration platform Powered by Perl Hosted by OICcam.com Ideas, requests, problems regarding TWiki? Send feedback. Ask community in the support forum.
Copyright © 1999-2017 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.