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
- add an attachment
- in de description field, use " or the XHTML equivalent
"
- upload
- in View, look at the form field: looks like a normal quote character
- click on the Action link
- in Attach, look at the form field: looks like a normal quote character where there was
"
- without changing, click Change properties
- in View again, look at the form field: looks like a normal quote character
- click again on Action
- 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
--
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
- change the attach script that it encodes the stored string (or should this be done in Meta.pm like it is now?)
- 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