Skip to content

Commit 4c47a9c

Browse files
committed
New version without bundled Apache Commons v2
Add org.apache.commons:commons-text dependency to pom.xml and core/pom.xml
1 parent a5031b1 commit 4c47a9c

5 files changed

Lines changed: 27 additions & 18 deletions

File tree

core/pom.xml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@
1212
</parent>
1313

1414
<dependencies>
15+
<dependency>
16+
<groupId>org.apache.commons</groupId>
17+
<artifactId>commons-text</artifactId>
18+
</dependency>
1519
<dependency>
1620
<groupId>commons-cli</groupId>
1721
<artifactId>commons-cli</artifactId>

core/src/com/biglybt/core/metasearch/Result.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
import java.net.URL;
2424
import java.util.*;
2525

26-
import org.apache.commons.lang.Entities;
26+
import org.apache.commons.text.StringEscapeUtils;
2727
import org.json.simple.JSONObject;
2828

2929
import com.biglybt.core.metasearch.utils.MomentsAgoDateFormatter;
@@ -512,6 +512,6 @@ protected static String unescapeEntities(String input )
512512
if ( input == null ){
513513
return( null );
514514
}
515-
return( Entities.HTML40.unescape( input ));
515+
return( StringEscapeUtils.unescapeHtml4( input ));
516516
}
517517
}

core/src/com/biglybt/core/metasearch/impl/web/WebResult.java

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121

2222
import java.util.*;
2323

24-
import org.apache.commons.lang.Entities;
24+
import org.apache.commons.text.StringEscapeUtils;
2525

2626
import com.biglybt.core.metasearch.Engine;
2727
import com.biglybt.core.metasearch.Result;
@@ -93,14 +93,14 @@ public void setName(String name) {
9393
public void setNameFromHTML(String name) {
9494
if(name != null) {
9595
name = removeHTMLTags(name);
96-
this.name = Entities.HTML40.unescape(name);
96+
this.name = StringEscapeUtils.unescapeHtml4(name);
9797
}
9898
}
9999

100100
public void setCommentsFromHTML(String comments) {
101101
if(comments != null) {
102102
comments = removeHTMLTags(comments);
103-
comments = Entities.HTML40.unescape(comments);
103+
comments = StringEscapeUtils.unescapeHtml4(comments);
104104
comments = comments.replaceAll(",", "");
105105
comments = comments.replaceAll(" ", "");
106106
try{
@@ -122,7 +122,7 @@ public void setCategoryFromHTML(String category) {
122122
if(category != null) {
123123
addTagFromHTML(category); // hack, we currently just pick up cats
124124
category = removeHTMLTags(category);
125-
this.category = Entities.HTML40.unescape(category).trim();
125+
this.category = StringEscapeUtils.unescapeHtml4(category).trim();
126126
/*int separator = this.category.indexOf(">");
127127
128128
if(separator != -1) {
@@ -144,7 +144,7 @@ public void setCategoryFromHTML(String category) {
144144
}
145145

146146
tag = removeHTMLTags( tag );
147-
tag = Entities.HTML40.unescape( tag ).trim();
147+
tag = StringEscapeUtils.unescapeHtml4( tag ).trim();
148148

149149
if ( !tag.isEmpty()){
150150

@@ -173,7 +173,7 @@ public void setCategoryFromHTML(String category) {
173173
public void setNbPeersFromHTML(String nbPeers) {
174174
if(nbPeers != null) {
175175
nbPeers = removeHTMLTags(nbPeers);
176-
String nbPeersS = Entities.HTML40.unescape(nbPeers);
176+
String nbPeersS = StringEscapeUtils.unescapeHtml4(nbPeers);
177177
nbPeersS = nbPeersS.replaceAll(",", "");
178178
nbPeersS = nbPeersS.replaceAll(" ", "");
179179
try {
@@ -188,7 +188,7 @@ public void setNbPeersFromHTML(String nbPeers) {
188188
public void setNbSeedsFromHTML(String nbSeeds) {
189189
if(nbSeeds != null) {
190190
nbSeeds = removeHTMLTags(nbSeeds);
191-
String nbSeedsS = Entities.HTML40.unescape(nbSeeds);
191+
String nbSeedsS = StringEscapeUtils.unescapeHtml4(nbSeeds);
192192
nbSeedsS = nbSeedsS.replaceAll(",", "");
193193
nbSeedsS = nbSeedsS.replaceAll(" ", "");
194194
try {
@@ -203,7 +203,7 @@ public void setNbSeedsFromHTML(String nbSeeds) {
203203
public void setNbSuperSeedsFromHTML(String nbSuperSeeds) {
204204
if(nbSuperSeeds != null) {
205205
nbSuperSeeds = removeHTMLTags(nbSuperSeeds);
206-
String nbSuperSeedsS = Entities.HTML40.unescape(nbSuperSeeds);
206+
String nbSuperSeedsS = StringEscapeUtils.unescapeHtml4(nbSuperSeeds);
207207
nbSuperSeedsS = nbSuperSeedsS.replaceAll(",", "");
208208
nbSuperSeedsS = nbSuperSeedsS.replaceAll(" ", "");
209209
try {
@@ -289,7 +289,7 @@ public void setPublishedDate(Date date) {
289289
public void setPublishedDateFromHTML(String publishedDate) {
290290
if(publishedDate != null && publishedDate.length() > 0) {
291291
publishedDate = removeHTMLTags(publishedDate);
292-
String publishedDateS = Entities.HTML40.unescape(publishedDate).replace((char)160,(char)32);
292+
String publishedDateS = StringEscapeUtils.unescapeHtml4(publishedDate).replace((char)160,(char)32);
293293
this.publishedDate = dateParser.parseDate(publishedDateS);
294294
}
295295
}
@@ -305,7 +305,7 @@ public void setAssetDate( String str ){
305305
public void setSizeFromHTML(String size, long minAcceptable) {
306306
if(size != null) {
307307
size = removeHTMLTags(size);
308-
String sizeS = Entities.HTML40.unescape(size).replace((char)160,(char)32);
308+
String sizeS = StringEscapeUtils.unescapeHtml4(size).replace((char)160,(char)32);
309309
sizeS = sizeS.replaceAll("<[^>]+>", " ");
310310
//Add a space between the digits and unit if there is none
311311
sizeS = sizeS.replaceFirst("(\\d)([a-zA-Z])", "$1 $2");
@@ -338,7 +338,7 @@ public void setSizeFromHTML(String size, long minAcceptable) {
338338
public void setVotesFromHTML(String votes_str) {
339339
if(votes_str != null) {
340340
votes_str = removeHTMLTags(votes_str);
341-
votes_str = Entities.HTML40.unescape(votes_str);
341+
votes_str = StringEscapeUtils.unescapeHtml4(votes_str);
342342
votes_str = votes_str.replaceAll(",", "");
343343
votes_str = votes_str.replaceAll(" ", "");
344344
try {
@@ -352,7 +352,7 @@ public void setVotesFromHTML(String votes_str) {
352352
public void setVotesDownFromHTML(String votes_str) {
353353
if(votes_str != null) {
354354
votes_str = removeHTMLTags(votes_str);
355-
votes_str = Entities.HTML40.unescape(votes_str);
355+
votes_str = StringEscapeUtils.unescapeHtml4(votes_str);
356356
votes_str = votes_str.replaceAll(",", "");
357357
votes_str = votes_str.replaceAll(" ", "");
358358
try {

core/src/com/biglybt/pifimpl/local/utils/xml/simpleparser/SimpleXMLParserDocumentImpl.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
import javax.xml.parsers.DocumentBuilder;
3232
import javax.xml.parsers.DocumentBuilderFactory;
3333

34-
import org.apache.commons.lang.Entities;
34+
import org.apache.commons.text.StringEscapeUtils;
3535
import org.w3c.dom.Document;
3636
import org.w3c.dom.Node;
3737
import org.xml.sax.*;
@@ -748,11 +748,11 @@ private String getParseExceptionInfo(SAXParseException spe) {
748748

749749
}else{
750750

751-
int num = Entities.HTML40.entityValue( ref );
751+
String decoded = StringEscapeUtils.unescapeHtml4("&" + ref + ";");
752752

753-
if ( num != -1 ){
753+
if ( decoded != null && !decoded.equals("&" + ref + ";") ){
754754

755-
replacement = "&#" + num + ";";
755+
replacement = decoded;
756756

757757
}else{
758758

pom.xml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,11 @@
6262
<artifactId>commons-cli</artifactId>
6363
<version>1.4</version>
6464
</dependency>
65+
<dependency>
66+
<groupId>org.apache.commons</groupId>
67+
<artifactId>commons-text</artifactId>
68+
<version>1.10.0</version>
69+
</dependency>
6570
</dependencies>
6671
</dependencyManagement>
6772

0 commit comments

Comments
 (0)