Project

General

Profile

Actions

Defect #40650

closed

Fix duplicate alt and title attributes when alt text is specified for attached images in Textile formatter

Added by Katsuya HIDAKA about 1 month ago. Updated 16 days ago.

Status:
Closed
Priority:
Normal
Assignee:
Category:
Text formatting
Target version:
Start date:
Due date:
% Done:

0%

Estimated time:
Resolution:
Fixed
Affected version:

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

Actions #1

Updated by Go MAEDA 24 days ago

  • Tracker changed from Patch to Defect
  • Target version set to 6.0.0

Setting the target version to 6.0.0.

Actions #2

Updated by Go MAEDA 16 days ago

  • Subject changed from Fix alt and title attributes when alt text is specified for attached images in Textile format. to Fix duplicate alt and title attributes when alt text is specified for attached images in Textile formatter
  • Category changed from Wiki to Text formatting
  • Status changed from New to Closed
  • Assignee set to Go MAEDA
  • Resolution set to Fixed

Committed the patches in r22844 and r22845.

Actions

Also available in: Atom PDF