commons-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Bruno P. Kinoshita (JIRA)" <>
Subject [jira] [Commented] (TEXT-66) StringEscapeUtils.UNESCAPE_JAVA - TODO
Date Mon, 22 May 2017 10:23:04 GMT


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:

class A { private final String regex = \"^a.*\\!\"; }

When unescaped, returns a valid Java code.

class A { private final String regex = "^a.*!"; }

Then if you in have the trailing token.

class A { private final String regex = \"^a.*\\!\"; }\\\\

It returns the unescaped invalid Java code (compiler won't like it).

class A { private final String regex = "^a.*!"; }\

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:

class A { infinite-loop }

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:
>             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

View raw message