From 93d032c527d85a43a3f181bfa69c8c43234d5637 Mon Sep 17 00:00:00 2001 From: Wojtek Zieba Date: Wed, 7 Aug 2024 16:35:28 +0200 Subject: [PATCH 1/3] Bump jsoup to 1.15.3 Version without reported security vulnerabilities --- build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index 4f3f2ac08..1b93073cb 100644 --- a/build.gradle +++ b/build.gradle @@ -79,7 +79,7 @@ ext { picassoVersion = '2.5.2' robolectricVersion = '4.11' jUnitVersion = '4.12' - jSoupVersion = '1.11.3' + jSoupVersion = '1.15.3' wordpressUtilsVersion = '3.5.0' espressoVersion = '3.0.1' From 9a1015d6b5232d9185ea44ccd5197f5cb3d3c4f7 Mon Sep 17 00:00:00 2001 From: Wojtek Zieba Date: Wed, 7 Aug 2024 16:45:49 +0200 Subject: [PATCH 2/3] Specify type lambda parameter in `Elements#filter` method It was `Element` when jsoup was `1.11.3` --- .../src/main/kotlin/org/wordpress/aztec/source/Format.kt | 9 ++++++--- .../kotlin/org/wordpress/aztec/util/CleaningUtils.kt | 7 ++++--- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/aztec/src/main/kotlin/org/wordpress/aztec/source/Format.kt b/aztec/src/main/kotlin/org/wordpress/aztec/source/Format.kt index 3ce74a33f..76ed497b5 100644 --- a/aztec/src/main/kotlin/org/wordpress/aztec/source/Format.kt +++ b/aztec/src/main/kotlin/org/wordpress/aztec/source/Format.kt @@ -5,6 +5,8 @@ import android.text.SpannableStringBuilder import android.text.TextUtils import org.jsoup.Jsoup import org.jsoup.nodes.Document +import org.jsoup.nodes.Element +import org.jsoup.select.Elements import org.wordpress.aztec.spans.AztecQuoteSpan import org.wordpress.aztec.spans.AztecVisualLinebreak import org.wordpress.aztec.spans.EndOfParagraphMarker @@ -30,9 +32,10 @@ object Format { CleaningUtils.cleanNestedBoldTags(doc) if (isCalypsoFormat) { // remove empty span tags - doc.select("*") - .filter { !it.hasText() && it.tagName() == "span" && it.childNodes().size == 0 } - .forEach { it.remove() } + val select: Elements = doc.select("*") + select.filter { element: Element -> + !element.hasText() && element.tagName() == "span" && element.childNodes().size == 0 + }.forEach { it.remove() } html = replaceAll(doc.body().html(), iframePlaceholder, "iframe") diff --git a/aztec/src/main/kotlin/org/wordpress/aztec/util/CleaningUtils.kt b/aztec/src/main/kotlin/org/wordpress/aztec/util/CleaningUtils.kt index 9ae74ebe9..ff37acfb8 100644 --- a/aztec/src/main/kotlin/org/wordpress/aztec/util/CleaningUtils.kt +++ b/aztec/src/main/kotlin/org/wordpress/aztec/util/CleaningUtils.kt @@ -2,6 +2,7 @@ package org.wordpress.aztec.util import org.jsoup.Jsoup import org.jsoup.nodes.Document +import org.jsoup.nodes.Element import org.jsoup.parser.Parser object CleaningUtils { @@ -10,12 +11,12 @@ object CleaningUtils { fun cleanNestedBoldTags(doc: Document) { // clean all nested tags that don't contain anything doc.select("b > b") - .filter { !it.hasText() } + .filter { element: Element -> !element.hasText() } .forEach { it.remove() } // unwrap text in between nested tags that have some text in them doc.select("b > b") - .filter { it.hasText() } + .filter { element: Element -> element.hasText() } .forEach { it.unwrap() } } @@ -25,4 +26,4 @@ object CleaningUtils { cleanNestedBoldTags(doc) return doc.html() } -} \ No newline at end of file +} From 5bee1c97376322727875b624ae26048542e608ae Mon Sep 17 00:00:00 2001 From: Wojtek Zieba Date: Thu, 8 Aug 2024 15:32:40 +0200 Subject: [PATCH 3/3] Inline `select` --- aztec/src/main/kotlin/org/wordpress/aztec/source/Format.kt | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/aztec/src/main/kotlin/org/wordpress/aztec/source/Format.kt b/aztec/src/main/kotlin/org/wordpress/aztec/source/Format.kt index 76ed497b5..057d9688e 100644 --- a/aztec/src/main/kotlin/org/wordpress/aztec/source/Format.kt +++ b/aztec/src/main/kotlin/org/wordpress/aztec/source/Format.kt @@ -6,7 +6,6 @@ import android.text.TextUtils import org.jsoup.Jsoup import org.jsoup.nodes.Document import org.jsoup.nodes.Element -import org.jsoup.select.Elements import org.wordpress.aztec.spans.AztecQuoteSpan import org.wordpress.aztec.spans.AztecVisualLinebreak import org.wordpress.aztec.spans.EndOfParagraphMarker @@ -32,8 +31,7 @@ object Format { CleaningUtils.cleanNestedBoldTags(doc) if (isCalypsoFormat) { // remove empty span tags - val select: Elements = doc.select("*") - select.filter { element: Element -> + doc.select("*").filter { element: Element -> !element.hasText() && element.tagName() == "span" && element.childNodes().size == 0 }.forEach { it.remove() }