[
https://issues.apache.org/jira/browse/TEXT-66?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16019410#comment-16019410
]
Bruno P. Kinoshita commented on TEXT-66:
----------------------------------------
I think we can probably close this issue as Won't Fix.
The comment suggests throwing an exception if there is an trailing \ at the
end of the Java text. So for instance, the following valid escaped Java:
{code:java}
class A { private final String regex = \"^a.*\\!\"; }
{code}
When unescaped, returns a valid Java code.
{code:java}
class A { private final String regex = "^a.*!"; }
{code}
Then if you in have the trailing token.
{code:java}
class A { private final String regex = \"^a.*\\!\"; }\\\\
{code}
It returns the unescaped invalid Java code (compiler won't like it).
{code:java}
class A { private final String regex = "^a.*!"; }\
{code}
The note seems to suggest throwing an exception for this case. But I think this
is not covered by the contract of the class. It simply tries to escape text,
using a certain lookup table for replacements, generating unescaped Java, but
not necessarily valid code. Otherwise we would have to care for other cases
like this invalid Java code that can also be unescaped with no exceptions:
{code:java}
class A { infinite-loop }
{code}
So I think we should simply close it, unless I missed something from the API or
if the comment meant something else?
> StringEscapeUtils.UNESCAPE_JAVA - TODO
> --------------------------------------
>
> Key: TEXT-66
> URL: https://issues.apache.org/jira/browse/TEXT-66
> Project: Commons Text
> Issue Type: Improvement
> Affects Versions: 1.0-beta-1
> Reporter: Rob Tompkins
> Fix For: 1.x
>
>
> To mitigate having checkstyle errors, we have added this Jira en lieu of the
> TODO comment in the code.
> throw "illegal character: \92" as an Exception if a \ on the end of the Java
> (as per the compiler)?
--
This message was sent by Atlassian JIRA
(v6.3.15#6346)