[
https://issues.apache.org/jira/browse/LANG-948?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13967824#comment-13967824
]
ASF GitHub Bot commented on LANG-948:
-------------------------------------
GitHub user Andrey-Khobnya opened a pull request:
https://github.com/apache/commons-lang/pull/19
Fix LANG-948
Hi all!
This is fix for bug LANG-948.
Changes with explanations:
1) Method ```ExtendedMessageFormat.appendQuotedString()``` returned when
finds first quote character. This is obviously wrong because quoted string
start with quote character and method must consume whole quoted string. I added
handling of first quote character at the beginning of method. Also, it doesn't
make sense to handle escaped quotes because
```super.applyPattern(stripCustom.toString())``` will called below in
```applyPattern()```. Thus, last argument should be ```false``` when calling
```appendQuotedString()```.
2) Quoted string must start with quote character in
```appendQuotedString()```. And at this moment method is used this way. I added
assertion to check and document this.
3) Thus, method ```appendQuotedString()``` is called with last argument
always ```false```. It doesn't make sense to handle escaped quotes in
```appendQuotedString()``` because they will be handled in
```super.applyPattern()```. Thus, I deleted this parameter and code for
handling escaped quotes.
You can merge this pull request into a Git repository by running:
$ git pull https://github.com/Andrey-Khobnya/commons-lang fix-948
Alternatively you can review and apply these changes as the patch at:
https://github.com/apache/commons-lang/pull/19.patch
To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:
This closes #19
----
commit 86e64df6ce7e879c5f608aa7276c251377574f56
Author: Andrey Khobnya <[email protected]>
Date: 2014-04-13T12:36:07Z
Fix LANG-948
commit 0f9222d5cccbe27fbda5ab9b97b231162e4b089b
Author: Andrey Khobnya <[email protected]>
Date: 2014-04-13T12:42:02Z
Add assertion in ExtendedMessageFormat.appendQuotedString() to check and
document proper usage
commit 4d372f3ce65087c8863332c74c2563a165d7aa12
Author: Andrey Khobnya <[email protected]>
Date: 2014-04-13T12:49:28Z
It doesn't make sense to handle escaped quotes in
ExtendedMessageFormat.appendQuotedString() because they will be handled
in super.applyPattern()
----
> Exception while using ExtendedMessageFormat and escaping braces
> ---------------------------------------------------------------
>
> Key: LANG-948
> URL: https://issues.apache.org/jira/browse/LANG-948
> Project: Commons Lang
> Issue Type: Bug
> Components: lang.text.*
> Affects Versions: 3.2, 3.2.1
> Reporter: Nicolò Chieffo
> Fix For: Patch Needed
>
> Attachments: TestExtendedMessageFormat.java,
> TestExtendedMessageFormat2.java
>
>
> Exception while trying to format a string containing escaped braces
> {code}
> Exception in thread "main" java.lang.IllegalArgumentException: Invalid format
> argument index at position 7: }
> at
> org.apache.commons.lang3.text.ExtendedMessageFormat.readArgumentIndex(ExtendedMessageFormat.java:357)
> at
> org.apache.commons.lang3.text.ExtendedMessageFormat.applyPattern(ExtendedMessageFormat.java:167)
> at
> org.apache.commons.lang3.text.ExtendedMessageFormat.<init>(ExtendedMessageFormat.java:128)
> at
> org.apache.commons.lang3.text.ExtendedMessageFormat.<init>(ExtendedMessageFormat.java:113)
> at
> test.TestExtendedMessageFormat.main(TestExtendedMessageFormat.java:16)
> {code}
> I will attach a source
--
This message was sent by Atlassian JIRA
(v6.2#6252)