Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@
</parent>

<dependencies>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-text</artifactId>
</dependency>
<dependency>
<groupId>commons-cli</groupId>
<artifactId>commons-cli</artifactId>
Expand Down
4 changes: 2 additions & 2 deletions core/src/com/biglybt/core/metasearch/Result.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
import java.net.URL;
import java.util.*;

import org.apache.commons.lang.Entities;
import org.apache.commons.text.StringEscapeUtils;
import org.json.simple.JSONObject;

import com.biglybt.core.metasearch.utils.MomentsAgoDateFormatter;
Expand Down Expand Up @@ -512,6 +512,6 @@ protected static String unescapeEntities(String input )
if ( input == null ){
return( null );
}
return( Entities.HTML40.unescape( input ));
return( StringEscapeUtils.unescapeHtml4( input ));
}
}
24 changes: 12 additions & 12 deletions core/src/com/biglybt/core/metasearch/impl/web/WebResult.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@

import java.util.*;

import org.apache.commons.lang.Entities;
import org.apache.commons.text.StringEscapeUtils;

import com.biglybt.core.metasearch.Engine;
import com.biglybt.core.metasearch.Result;
Expand Down Expand Up @@ -93,14 +93,14 @@ public void setName(String name) {
public void setNameFromHTML(String name) {
if(name != null) {
name = removeHTMLTags(name);
this.name = Entities.HTML40.unescape(name);
this.name = StringEscapeUtils.unescapeHtml4(name);
}
}

public void setCommentsFromHTML(String comments) {
if(comments != null) {
comments = removeHTMLTags(comments);
comments = Entities.HTML40.unescape(comments);
comments = StringEscapeUtils.unescapeHtml4(comments);
comments = comments.replaceAll(",", "");
comments = comments.replaceAll(" ", "");
try{
Expand All @@ -122,7 +122,7 @@ public void setCategoryFromHTML(String category) {
if(category != null) {
addTagFromHTML(category); // hack, we currently just pick up cats
category = removeHTMLTags(category);
this.category = Entities.HTML40.unescape(category).trim();
this.category = StringEscapeUtils.unescapeHtml4(category).trim();
/*int separator = this.category.indexOf(">");

if(separator != -1) {
Expand All @@ -144,7 +144,7 @@ public void setCategoryFromHTML(String category) {
}

tag = removeHTMLTags( tag );
tag = Entities.HTML40.unescape( tag ).trim();
tag = StringEscapeUtils.unescapeHtml4( tag ).trim();

if ( !tag.isEmpty()){

Expand Down Expand Up @@ -173,7 +173,7 @@ public void setCategoryFromHTML(String category) {
public void setNbPeersFromHTML(String nbPeers) {
if(nbPeers != null) {
nbPeers = removeHTMLTags(nbPeers);
String nbPeersS = Entities.HTML40.unescape(nbPeers);
String nbPeersS = StringEscapeUtils.unescapeHtml4(nbPeers);
nbPeersS = nbPeersS.replaceAll(",", "");
nbPeersS = nbPeersS.replaceAll(" ", "");
try {
Expand All @@ -188,7 +188,7 @@ public void setNbPeersFromHTML(String nbPeers) {
public void setNbSeedsFromHTML(String nbSeeds) {
if(nbSeeds != null) {
nbSeeds = removeHTMLTags(nbSeeds);
String nbSeedsS = Entities.HTML40.unescape(nbSeeds);
String nbSeedsS = StringEscapeUtils.unescapeHtml4(nbSeeds);
nbSeedsS = nbSeedsS.replaceAll(",", "");
nbSeedsS = nbSeedsS.replaceAll(" ", "");
try {
Expand All @@ -203,7 +203,7 @@ public void setNbSeedsFromHTML(String nbSeeds) {
public void setNbSuperSeedsFromHTML(String nbSuperSeeds) {
if(nbSuperSeeds != null) {
nbSuperSeeds = removeHTMLTags(nbSuperSeeds);
String nbSuperSeedsS = Entities.HTML40.unescape(nbSuperSeeds);
String nbSuperSeedsS = StringEscapeUtils.unescapeHtml4(nbSuperSeeds);
nbSuperSeedsS = nbSuperSeedsS.replaceAll(",", "");
nbSuperSeedsS = nbSuperSeedsS.replaceAll(" ", "");
try {
Expand Down Expand Up @@ -289,7 +289,7 @@ public void setPublishedDate(Date date) {
public void setPublishedDateFromHTML(String publishedDate) {
if(publishedDate != null && publishedDate.length() > 0) {
publishedDate = removeHTMLTags(publishedDate);
String publishedDateS = Entities.HTML40.unescape(publishedDate).replace((char)160,(char)32);
String publishedDateS = StringEscapeUtils.unescapeHtml4(publishedDate).replace((char)160,(char)32);
this.publishedDate = dateParser.parseDate(publishedDateS);
}
}
Expand All @@ -305,7 +305,7 @@ public void setAssetDate( String str ){
public void setSizeFromHTML(String size, long minAcceptable) {
if(size != null) {
size = removeHTMLTags(size);
String sizeS = Entities.HTML40.unescape(size).replace((char)160,(char)32);
String sizeS = StringEscapeUtils.unescapeHtml4(size).replace((char)160,(char)32);
sizeS = sizeS.replaceAll("<[^>]+>", " ");
//Add a space between the digits and unit if there is none
sizeS = sizeS.replaceFirst("(\\d)([a-zA-Z])", "$1 $2");
Expand Down Expand Up @@ -338,7 +338,7 @@ public void setSizeFromHTML(String size, long minAcceptable) {
public void setVotesFromHTML(String votes_str) {
if(votes_str != null) {
votes_str = removeHTMLTags(votes_str);
votes_str = Entities.HTML40.unescape(votes_str);
votes_str = StringEscapeUtils.unescapeHtml4(votes_str);
votes_str = votes_str.replaceAll(",", "");
votes_str = votes_str.replaceAll(" ", "");
try {
Expand All @@ -352,7 +352,7 @@ public void setVotesFromHTML(String votes_str) {
public void setVotesDownFromHTML(String votes_str) {
if(votes_str != null) {
votes_str = removeHTMLTags(votes_str);
votes_str = Entities.HTML40.unescape(votes_str);
votes_str = StringEscapeUtils.unescapeHtml4(votes_str);
votes_str = votes_str.replaceAll(",", "");
votes_str = votes_str.replaceAll(" ", "");
try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;

import org.apache.commons.lang.Entities;
import org.apache.commons.text.StringEscapeUtils;
import org.w3c.dom.Document;
import org.w3c.dom.Node;
import org.xml.sax.*;
Expand Down Expand Up @@ -748,11 +748,11 @@ private String getParseExceptionInfo(SAXParseException spe) {

}else{

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

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

replacement = "&#" + num + ";";
replacement = decoded;

}else{

Expand Down
Loading
Loading