[MGNLDIFF-15] java.lang.IndexOutOfBoundsException When Content Contains Dollar Sign ($) Created: 16/Apr/12  Updated: 14/Dec/12  Resolved: 17/Apr/12

Status: Closed
Project: Magnolia Diff Module
Component/s: None
Affects Version/s: 1.0.3, 1.1, 1.1.1
Fix Version/s: 1.0.4, 1.1.2

Type: Bug Priority: Neutral
Reporter: Adam Galloway Assignee: Ondrej Chytil
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

Magnolia 4.4.4 and Magnolia 4.5


Attachments: File diff-module-with-body-tag.patch    
Issue Links:
causality
Template:
Acceptance criteria:
Empty
Task DoD:
[ ]* Doc/release notes changes? Comment present?
[ ]* Downstream builds green?
[ ]* Solution information and context easily available?
[ ]* Tests
[ ]* FixVersion filled and not yet released
[ ]  Architecture Decision Record (ADR)
Bug DoR:
[ ]* Steps to reproduce, expected, and actual results filled
[ ]* Affected version filled
Date of First Response:

 Description   

When using "Compare with previous" link in the "Edit Workitem" dialog an error is thrown stating: java.lang.IndexOutOfBoundsException: No group 6

This is appears to be related to there being a $ dollar sign in the content of the versions being compared. Removing the dollar sign allows comparison page to render.

The stack trace is (for version 1.0.3, similar but different exception in newer version):

java.lang.IndexOutOfBoundsException: No group 6
java.util.regex.Matcher.group(Matcher.java:470)
java.util.regex.Matcher.appendReplacement(Matcher.java:737)
java.util.regex.Matcher.replaceFirst(Matcher.java:861)
java.lang.String.replaceFirst(String.java:2146)
info.magnolia.module.diff.VersionDiffHtmlGenerator.diff(VersionDiffHtmlGenerator.java:81)
info.magnolia.module.diff.VersionDiffHtmlServlet.getVersionDiffHtml(VersionDiffHtmlServlet.java:171)
info.magnolia.module.diff.VersionDiffHtmlServlet.doGet(VersionDiffHtmlServlet.java:96)
javax.servlet.http.HttpServlet.service(HttpServlet.java:621)

Additional Info: http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6325587
I have tried this with both Java 1.5 and 1.6 with the same results.

Steps to reproduce:

Go to http://demo.magnolia-cms.com
Open demo-project/service page
Edit the "Internal Page Teaser" by adding a $ to the "Teaser Overwrite" text
Activate changes
Open and edit the same page again
Submit the activation for approval
Use the "Compare with previous" link on the "Edit Workitem" dialog
See the error



 Comments   
Comment by Adam Galloway [ 16/Apr/12 ]

Attached a simple patch that uses sub strings instead of regex to build response html. Also removed duplicate doctype that gets injected into the body of the response html for the comparison.

Comment by Jan Haderka [ 16/Apr/12 ]

Thanks Adam. Going to include it in the next release.

Comment by Adam Galloway [ 17/Apr/12 ]

Just realized that the previous patch excludes attributes on the body tag. Attaching an updated patch that takes care of that.

Comment by Ondrej Chytil [ 17/Apr/12 ]

Thanks for patch Adam.

Generated at Mon Feb 12 05:20:32 CET 2024 using Jira 9.4.2#940002-sha1:46d1a51de284217efdcb32434eab47a99af2938b.