Why is org.apache.common.lang3 StringEscapeUtils deprecated?

I could not find an explanation of why StringEscapeUtils was deprecated from Apache Lang3 v3.7.

https://commons.apache.org/proper/commons-lang/apidocs/org/apache/commons/lang3/StringEscapeUtils.html

What should we use now for HTML escaping / unescaping

+18
source share
4 answers

The class has been moved from the package.

org.apache.commons. lang3

in

org.apache.commons. text

You can easily replace the obsolete library:

In your build.gradle:

implementation 'org.apache.commons:commons-text:1.6' 

And in your class using StringEscapeUtils make sure you import the correct class:

 import org.apache.commons.text.StringEscapeUtils; 

1.6 is currently the most recent version (last check out is May 2, 2019), but you can check the versions on maven: https://mvnrepository.com/artifact/org.apache.commons/commons-text

+19
source

In the obsolete list , it was moved to a new project - commons-text

+10
source

From Commons-lang 3.6 Release Notes :

The Apache Commons community recently installed the Commons Text component as the basis for string-based algorithms. For this reason, most of the line-oriented functionality in Commons Lang is deprecated and ported to Commons Text. This includes:

o All classes in org.apache.commons.lang3.text and org.apache.commons.lang3.text.translate packages. o org.apache.commons.lang3.StringEscapeUtils. o org.apache.commons.lang3.RandomStringUtils. o methods org.apache.commons.lang3.StringUtils.getJaroWinklerDistance and org.apache.commons.lang3.StringUtils.getLevenshteinDistance

For more information, visit the Commons Text website:

 http://commons.apache.org/text 
+6
source

Take below steps

  • Add below dependency to your pom.xml (if using maven)
    <dependence>
    <group_id> org.apache.commons </group_id>
    <artifact> general text </ artifact>
    <version> 1.4 </i>
    <dependence>

  • Import the correct package as below
    import org.apache.commons.text.StringEscapeUtils;

  • This class no longer has such a unescapeHtml () method; instead, two of its variants, unescapeHtml3 () and unescapeHtml4 () are available.
  • Use unescapeHtml3 () to remove Html 3.0 characters
  • Use unescapeHtml4 () to remove Html 4.0 characters
+1
source

Source: https://habr.com/ru/post/1274067/


All Articles