From 8c2b920b3548f95146c25e297b9371a0793b30fd Mon Sep 17 00:00:00 2001 From: Conner Bradley Date: Thu, 8 Sep 2022 15:32:58 -0400 Subject: [PATCH] Fix breaking changes between JSoup 1.14.2 to 1.15.3 JSoup replaced org.jsoup.safety.Whitelist with org.jsoup.safety.Safelist. Purely a naming change, no difference of functionality. This bumps the JSoup version (re: https://github.com/jagrosh/JLyrics/pull/10) and handles the breaking changes. This is needed as the related MusicBot project has recently bumped the JSoup version to 1.15.3 (re: https://github.com/jagrosh/MusicBot/commit/a7be2c4602680cdfc48b7d19cb90cb19b3ba7151) causing runtime errors as it depends on JLyrics, which depends on a different JSoup version. --- pom.xml | 2 +- src/main/java/com/jagrosh/jlyrics/LyricsClient.java | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/pom.xml b/pom.xml index c0e895f..8f88d44 100644 --- a/pom.xml +++ b/pom.xml @@ -10,7 +10,7 @@ org.jsoup jsoup - 1.14.2 + 1.15.3 jar diff --git a/src/main/java/com/jagrosh/jlyrics/LyricsClient.java b/src/main/java/com/jagrosh/jlyrics/LyricsClient.java index 319b0d4..a7169df 100644 --- a/src/main/java/com/jagrosh/jlyrics/LyricsClient.java +++ b/src/main/java/com/jagrosh/jlyrics/LyricsClient.java @@ -31,7 +31,7 @@ import org.jsoup.nodes.Document; import org.jsoup.nodes.Document.OutputSettings; import org.jsoup.nodes.Element; -import org.jsoup.safety.Whitelist; +import org.jsoup.safety.Safelist; /** * @@ -42,7 +42,7 @@ public class LyricsClient private final Config config = ConfigFactory.load(); private final HashMap cache = new HashMap<>(); private final OutputSettings noPrettyPrint = new OutputSettings().prettyPrint(false); - private final Whitelist newlineWhitelist = Whitelist.none().addTags("br", "p"); + private final Safelist newlineSafelist = Safelist.none().addTags("br", "p"); private final Executor executor; private final String defaultSource, userAgent; private final int timeout; @@ -178,6 +178,6 @@ public CompletableFuture getLyrics(String search, String source) private String cleanWithNewlines(Element element) { - return Jsoup.clean(Jsoup.clean(element.html(), newlineWhitelist), "", Whitelist.none(), noPrettyPrint); + return Jsoup.clean(Jsoup.clean(element.html(), newlineSafelist), "", Safelist.none(), noPrettyPrint); } }