Edgewall Software

Opened 12 years ago

Last modified 12 years ago

#10668 closed defect

Cut and paste of attachment name leads to zero-width character in string, preventing image macro from displaying attachment — at Version 11

Reported by: Ryan J Ollos <ryano@…> Owned by:
Priority: normal Milestone: 1.0
Component: wiki system Version: 0.12.3
Severity: normal Keywords: attachment link
Cc: Branch:
Release Notes:
API Changes:
Internal Changes:

Description (last modified by Christian Boos)

The following scenario might qualify as user error, but I could imagine some other users making the error, so I thought it might be worthwhile to report it.

The scenario is, I frequently upload image attachments with long filenames. Being lazy and not wanting to type out some long filename, I highlight and copy the filename from the attachment section of the ticket, and paste the filename into the comment box, inside a call to the Image macro. Frequently, I find that the Image macro can't link to the attachment, even though everything looks fine in the wiki markup.

The issue seems to be that a zero width UTF character (E2 80 8B) can get inserted into the comment box during the paste operation, but they are not visible in the comment dialog. Clicking on the attachment though, we get URLs like like /attachment/ticket/1228/MilestoneProgressBar.png%E2%80%8B, which is what pointed me towards the issue.

I'll show some screen captures and then attempt to demonstrate the issue. I tested this out before posting here in demo-0.12:ticket/5002.





Related branches

Change History (16)

by Ryan J Ollos <ryano@…>, 12 years ago

Attachment: Attachment.png added

by Ryan J Ollos <ryano@…>, 12 years ago

Attachment: AddAndThenEditAComment.png added

by Ryan J Ollos <ryano@…>, 12 years ago

Attachment: AttachmentNotLinked.png added

by Ryan J Ollos <ryano@…>, 12 years ago

Attachment: InvalidAttachment.png added

comment:1 by Ryan J Ollos <ryano@…>, 12 years ago

Description: modified (diff)

by Ryan J Ollos <ryano@…>, 12 years ago

Attachment: MilestoneProgressBar.png added

comment:2 by Ryan J Ollos <ryano@…>, 12 years ago

Example:

  1. Highlight MilestoneProgressBar.png in the attachment section (#no1).
  2. Copy.
  3. Paste the filename as the argument for a call to the image macro.

comment:3 by Christian Boos, 12 years ago

That's a bit unfortunate, this character is there to avoid having the download icon and link split on different lines.

What would happen with a Soft_hyphen or even a Zero-width_joiner?

comment:4 by Ryan J Ollos <ryano@…>, 12 years ago

Summary: Cut and paste of attachment name leads to zero-width in string, preventing image macro from displaying attachmentCut and paste of attachment name leads to zero-width character in string, preventing image macro from displaying attachment

I can do some testing tonight or tomorrow night and get back to you.

in reply to:  3 ; comment:5 by Remy Blank, 12 years ago

Replying to cboos:

That's a bit unfortunate, this character is there to avoid having the download icon and link split on different lines.

Even worse, it's there to avoid having an empty <a></a> pair for the download icon. IIRC some browsers don't render the padding correctly when there's nothing between the opening and closing tag, therefore hiding the background image. With the ZWS, it renders correctly in all browsers.

What would happen with a Soft_hyphen or even a Zero-width_joiner?

I haven't tried, but I expect that copy / pasting will also copy them.

comment:6 by Ryan J Ollos <ryano@…>, 12 years ago

Something that I found odd is that the relative href is /attachment/ticket/10668/MilestoneProgressBar.png%E2%80%8B, but the error message is Attachment 'ticket:10668: MilestoneProgressBar.png​ does not exist. The space is in front of the filename in the error message, but the unicode character is appended to the end of the href.

in reply to:  6 comment:7 by Ryan J Ollos <ryano@…>, 12 years ago

Replying to Ryan J Ollos <ryano@…>:

The space is in front of the filename in the error message, but the unicode character is appended to the end of the href.

It looks like the space in front of the filename has nothing to do with the issue I'm reporting here. I had never noticed this before, but a space is added between the realm and resource in the error message, e.g. here is one I saw today, Attachment 'ticket:1227: trac.ini.20120419' does not exist. It seems like that space is probably unintended.

in reply to:  5 comment:8 by Jun Omae, 12 years ago

Replying to cboos:

That's a bit unfortunate, this character is there to avoid having the download icon and link split on different lines.

Using content css property (e.g. content: "\00200b") also avoids the splitting. However IE6/7 don't support the property. And the text inserted by the property cannot be copied to clipboard, but excepted Opera and IE.

Replying to rblank:

Even worse, it's there to avoid having an empty <a></a> pair for the download icon. IIRC some browsers don't render the padding correctly when there's nothing between the opening and closing tag, therefore hiding the background image. With the ZWS, it renders correctly in all browsers.

.trac-rawlink { *zoom: 1 } css hack avoids hiding the background image for an empty <a></a> pair on IE6/7.

I worked in d3e199d/jomae.git.

  • Works fine on Firefox 12, Chrome 19 and Safari 5.1.
  • U+200B is copied on Opera 11 and IE8. The icon and link aren't split.
  • The icon and link are split on IE6/7. U+200B isn't copied.

Thoughts?

Last edited 12 years ago by Jun Omae (previous) (diff)

comment:9 by Christian Boos, 12 years ago

Testing d3e199d/jomae.git, for me the raw attachment icon is sometimes split from the link (FF 12, IE9). But worse, the original problem is not fixed for Opera or IE9 for example. So the proposed fix is probably not the final word on the topic, though it's a progress for some browsers (Chrome and FF).

comment:10 by Christian Boos, 12 years ago

Regardless of whether we should support having the icon wrap on the next line or not (\u200b should in fact facilitate this splitting, no?), a different approach would be to simply be robust against the possible presence of \u200b in the link when parsing it… (approach I've used for #10713).

comment:11 by Christian Boos, 12 years ago

Description: modified (diff)
Keywords: attachment link added
Milestone: 0.13

While waiting for the Attach branch feature…

Note: See TracTickets for help on using tickets.