Aryan Ganjoo created EXEC-125:
---------------------------------

             Summary: StringUtils.stringSubstitution crashes on a trailing 
dollar sign
                 Key: EXEC-125
                 URL: https://issues.apache.org/jira/browse/EXEC-125
             Project: Commons Exec
          Issue Type: Bug
            Reporter: Aryan Ganjoo


When CommandLine uses a substitution map, an argument ending in a literal '$' 
can crash in StringUtils.stringSubstitution(). The '$' case reads 
argStr.charAt(cIdx + 1) even when cIdx is the final character, raising 
StringIndexOutOfBoundsException instead of preserving the literal dollar sign. 
An unterminated ${... expression at the end also reads beyond the input rather 
than reporting a missing delimiter.

Reproduction on current Commons Exec master 
(0fe4841ac471ebaa2964120d672e341e0f749c5b):
1. Create a CommandLine with arguments end$ and ${file}.
2. Set a substitution map containing file -> a.txt.
3. Call toStrings(). The trailing-dollar argument triggers 
StringIndexOutOfBoundsException.

Expected: the literal end$ argument is preserved while ${file} expands to 
a.txt; an unterminated ${... expression reports IllegalArgumentException for 
its missing delimiter.

A focused regression was reproduced failing on the unmodified base and passing 
with a local bounds check. The local patch has passed independent technical 
review; no PR or hosted CI result exists yet. This is separate from EXEC-39's 
quoting and substitution-key documentation report.

Prepared with AI assistance.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to