From 3b2babd4a444199df947ed9d2460a1e9b58581a6 Mon Sep 17 00:00:00 2001 From: =?utf8?q?David=20=E2=80=98Bombe=E2=80=99=20Roden?= Date: Wed, 28 Jan 2015 06:28:17 +0100 Subject: [PATCH] Prevent empty or formatted strings from being parsed as a number. --- .../rhynodge/filters/torrents/TorrentzEuFilter.java | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/main/java/net/pterodactylus/rhynodge/filters/torrents/TorrentzEuFilter.java b/src/main/java/net/pterodactylus/rhynodge/filters/torrents/TorrentzEuFilter.java index 57be6f0..2b071c0 100644 --- a/src/main/java/net/pterodactylus/rhynodge/filters/torrents/TorrentzEuFilter.java +++ b/src/main/java/net/pterodactylus/rhynodge/filters/torrents/TorrentzEuFilter.java @@ -46,12 +46,19 @@ public class TorrentzEuFilter extends TorrentSiteFilter { @Override protected int extractSeedCount(Element dataRow) { - return Integer.valueOf(dataRow.select("dd span.u").text()); + return extractNumber(dataRow.select("dd span.u").text()); } @Override protected int extractLeechCount(Element dataRow) { - return Integer.valueOf(dataRow.select("dd span.d").text()); + return extractNumber(dataRow.select("dd span.d").text()); + } + + private int extractNumber(String text) { + if ((text == null) || text.isEmpty()) { + return 0; + } + return Integer.valueOf(text.replace(",", "")); } } -- 2.7.4