Skip to content

Comments

fix(thumbnail): escape + character in SVG MIME type regex pattern#3032

Merged
marevol merged 1 commit intomasterfrom
fix/svg-mimetype-regex-escape
Jan 31, 2026
Merged

fix(thumbnail): escape + character in SVG MIME type regex pattern#3032
marevol merged 1 commit intomasterfrom
fix/svg-mimetype-regex-escape

Conversation

@marevol
Copy link
Contributor

@marevol marevol commented Jan 31, 2026

Summary

Fixed an issue where SVG thumbnails were not being generated due to incorrect regex pattern matching for the image/svg+xml MIME type.

Changes Made

  • fess_thumbnail.xml: Changed the MIME type condition from image/svg+xml to image/svg\+xml to properly escape the + character for regex matching
  • BaseThumbnailGeneratorTest.java: Added test case test_mimetypePatternMatching() to verify regex pattern behavior and prevent regression

Problem

The + character in regex means "one or more of the preceding element", so the pattern image/svg+xml was being interpreted as "image/svg" followed by one or more "x" followed by "ml". This caused the pattern to not match the literal string image/svg+xml.

Solution

Escaped the + character with a backslash (\+) so it matches the literal + in the MIME type string.

Testing

  • Added unit test that demonstrates:
    • The unescaped pattern fails to match image/svg+xml
    • The escaped pattern correctly matches image/svg+xml
    • Other common MIME types without special characters continue to work

🤖 Generated with Claude Code

The MIME type condition for SVG thumbnail generation was using
"image/svg+xml" as a regex pattern without escaping the + character.
In regex, + is a special character meaning "one or more", which
caused the pattern to not match the literal "image/svg+xml" string.

Changed the pattern to "image/svg\+xml" to properly match the SVG
MIME type and enable thumbnail generation for SVG files.

Added test case to verify the regex pattern matching behavior.
@marevol marevol self-assigned this Jan 31, 2026
@marevol marevol added this to the 15.5.0 milestone Jan 31, 2026
@marevol marevol merged commit 14f1f74 into master Jan 31, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant