fix(crawler): escape + character in MIME type regex patterns#3035
Merged
fix(crawler): escape + character in MIME type regex patterns#3035
Conversation
Escape the + character in regex patterns for MIME types containing + in crawler/rule.xml (application/xhtml+xml, application/rdf+xml) and fix double-escaped pattern in fess_thumbnail.xml (image/svg+xml). The + character has special meaning in regex (one or more of previous), so it must be escaped with backslash to match literally. Add comprehensive unit tests for MIME type pattern matching. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR extends the regex pattern fix from #3032 to escape the
+character in additional MIME type patterns:+inapplication/xhtml+xmlandapplication/rdf+xmlpatterns for bothwebFileRuleandfsFileRule\\+to single-escaped\+forimage/svg+xmlpatternChanges Made
+character inapplication/xhtml+xmlregex pattern (webFileRule, fsFileRule)+character inapplication/rdf+xmlregex pattern (webFileRule, fsFileRule)image/svg\\+xmltoimage/svg\+xmlin thumbnail generator configCrawlerRuleMimeTypePatternTest.javaBaseThumbnailGeneratorTest.javaTechnical Details
The
+character has special meaning in regex (matches "one or more" of the previous character). Without escaping, patterns likeapplication/xhtml+xmlwould not match the literal MIME type string because the regex engine interpretsl+as "one or more 'l' characters" rather than the literal sequencel+.Testing
CrawlerRuleMimeTypePatternTest.javawith 18 test cases covering:+fails to match)BaseThumbnailGeneratorTest.javawith tests forisTarget()method with SVG, XHTML, and RDF MIME types🤖 Generated with Claude Code