Patch #26682

URL-escape the ! character in generated markup for dropped uploads

Added by Holger Just 3 months ago. Updated about 1 month ago.

Status:ClosedStart date:
Priority:NormalDue date:
Assignee:Jean-Philippe Lang% Done:

0%

Category:Text formatting
Target version:3.4.3

Description

In #26071, we introduced the ability to just drag an image into a textbox and have Redmine generate the correct image markup for the uploaded file for easy inclusion.

Unfortunately, the ! character in the filename is not escaped here. Thus, when using Textile as the markup language and if the filename of the dropped file contains a ! character, the resulting markup will be invalid and the image will not be correctly referenced in the generated HTML.

The attached patch fixes this by explicitly percent-escaping the exclamation mark. While this step is not strictly required for markdown, it doesn't hurt there since the escaped version is strictly equivalent to the unescaped one for URLs.

0001-URL-escape-the-character-in-generated-markup-for-dro.patch Magnifier (1.05 KB) Holger Just, 2017-08-14 15:24

26682-before@2x.png (15 KB) Go MAEDA, 2017-08-15 04:31

26682-after@2x.png (15.4 KB) Go MAEDA, 2017-08-15 04:31

parentheses@2x.png (10.7 KB) Go MAEDA, 2017-08-15 04:53

0001-URL-escape-additional-characters-with-special-meanin.patch Magnifier (1.16 KB) Holger Just, 2017-08-15 12:11


Related issues

Related to Redmine - Feature #26071: Generate markup for uploaded image dropped into wiki-edit... Closed

Associated revisions

Revision 16995
Added by Jean-Philippe Lang about 1 month ago

URL-escape additional characters with special meaning in the generated markup for dropped uploads (#26682).

Patch by Holger Just.

History

#1 Updated by Go MAEDA 3 months ago

Confirmed the problem. Setting target version to 3.4.3.
Thank you for sharing the patch.

Before:

After:

#2 Updated by Go MAEDA 3 months ago

  • File parentheses@2x.png added
  • Status changed from New to Needs feedback
  • Assignee set to Holger Just

'(' and ')' have to be escaped for Markdown formatter.
Holger, would you update the patch to escape those characters?

#3 Updated by Holger Just 3 months ago

Thank you for the review Maeda-san. I had a look at the Markdown generation but completely missed the parenthesis. In addition to that, it turns out that in my previous patch, only the first instance of an exclamation mark would have been escaped

The attached patch fixes both of these issues. It completely supersedes the previous patch.

#4 Updated by Go MAEDA 3 months ago

  • Status changed from Needs feedback to New
  • Assignee deleted (Holger Just)

I have tested the updated patch (#26682#note-3). Now it works fine in both Markdown and Textile.
Thank you for updating the patch so quickly.

#5 Updated by Go MAEDA 3 months ago

  • Related to Feature #26071: Generate markup for uploaded image dropped into wiki-edit textarea added

#6 Updated by Jean-Philippe Lang about 1 month ago

  • Status changed from New to Closed
  • Assignee set to Jean-Philippe Lang

Patch committed, thanks.

Also available in: Atom PDF