Project

General

Profile

Actions

Patch #40650

open

Fix alt and title attributes when alt text is specified for attached images in Textile format.

Added by Katsuya HIDAKA 14 days ago. Updated about 15 hours ago.

Status:
New
Priority:
Normal
Assignee:
-
Category:
Wiki
Target version:
-
Start date:
Due date:
% Done:

0%

Estimated time:

Description

This patch fixes the following problems when specifying alt text for attached images in Textile format.

  • When a description is set for an attached image, the specified alt text is ignored and the description of the attached image takes effect.
  • Incorrect img tags are generated with duplicate definitions of alt and title attributes.
!ruby-logo.png(alt text)!

When “description” is set in the description of the attached image ruby-logo.png, the result of the above Textile is as follows

Wiki (when hovering over the image) Generated HTML
<img src="/attachments/download/31/logo.png" 
  title="description" alt="description" 
  loading="lazy" 
  title="alt text" alt="alt text" /></p>

The current implementation expects to generate an img tag with “alt text” applied to the alt and title attributes, but actually generates an img tag with “description” applied.

This is due to the fact that the img tag defines two alt attributes (title attribute) with the values “alt text” and “description”; the HTML specification does not allow duplicate attributes (13.1.2.3 Attributes), and attributes defined later are ignored.

The result after applying the attached patch is as follows

Wiki (when hovering over the image) Generated HTML
<img src="/attachments/download/31/logo.png" 
  title="alt text" alt="alt text" 
  loading="lazy" /></p>

The CommonMark format should not be affected by this problem. Please see the attached test code for the first and second patches.

My environment is as follows

Environment:
  Redmine version                5.1.2.devel
  Ruby version                   3.3.1-p55 (2024-04-23) [x86_64-linux]
  Rails version                  7.1.2
  Environment                    development
  Database adapter               SQLite
  Mailer queue                   ActiveJob::QueueAdapters::AsyncAdapter
  Mailer delivery                smtp
Redmine settings:
  Redmine theme                  Default
SCM:
  Subversion                     1.14.2
  Mercurial                      6.3.2
  Cvs                            1.12.13
  Bazaar                         3.3.2
  Git                            2.39.2
  Filesystem                     
Redmine plugins:
  no plugin installed

Files

No data to display

Actions

Also available in: Atom PDF