Modern Apps git

← Modern-Apps.git

youpipe: replace jsoup with inline html escaping and drop the dead feed extractors

Commit
724e9ef4ac13b9ba0de813a7a03c6ab901e47a14
Author
Vayun Mathur <[email protected]>
When
2026-08-05 22:14 UTC (4 months ago)
Parents
55aac9c

Diff

youpipe/extractor/build.gradle.kts
diff --git a/youpipe/extractor/build.gradle.kts b/youpipe/extractor/build.gradle.ktsindex f5bd50ff13..8d7062c541 100644--- a/youpipe/extractor/build.gradle.kts+++ b/youpipe/extractor/build.gradle.kts@@ -4,8 +4,7 @@ plugins { }  dependencies {-    // nanojson removed — replaced by kotlinx.serialization-json via common-conventions-jvm-    implementation(libs.jsoup)+    // nanojson removed — replaced by kotlinx.serialization.json via common-conventions-jvm     implementation(libs.google.jsr305)     implementation(libs.protobuf.javalite)     implementation(libs.brotli.dec)
youpipe/extractor/src/main/kotlin/org/schabi/newpipe/extractor/StreamingService.kt
diff --git a/youpipe/extractor/src/main/kotlin/org/schabi/newpipe/extractor/StreamingService.kt b/youpipe/extractor/src/main/kotlin/org/schabi/newpipe/extractor/StreamingService.ktindex 5a8b637646..e979392875 100644--- a/youpipe/extractor/src/main/kotlin/org/schabi/newpipe/extractor/StreamingService.kt+++ b/youpipe/extractor/src/main/kotlin/org/schabi/newpipe/extractor/StreamingService.kt@@ -5,7 +5,6 @@ import org.schabi.newpipe.extractor.channel.tabs.ChannelTabExtractor import org.schabi.newpipe.extractor.comments.CommentsExtractor import org.schabi.newpipe.extractor.exceptions.ExtractionException import org.schabi.newpipe.extractor.exceptions.ParsingException-import org.schabi.newpipe.extractor.feed.FeedExtractor import org.schabi.newpipe.extractor.kiosk.KioskList import org.schabi.newpipe.extractor.linkhandler.LinkHandler import org.schabi.newpipe.extractor.linkhandler.LinkHandlerFactory@@ -23,7 +22,6 @@ import org.schabi.newpipe.extractor.stream.StreamExtractor import org.schabi.newpipe.extractor.subscription.SubscriptionExtractor import org.schabi.newpipe.extractor.suggestion.SuggestionExtractor import org.schabi.newpipe.extractor.utils.Utils-import javax.annotation.Nullable  abstract class StreamingService(     @get:JvmName("getServiceId") val serviceId: Int,@@ -49,10 +47,6 @@ abstract class StreamingService(     abstract fun getSuggestionExtractor(): SuggestionExtractor     abstract fun getSubscriptionExtractor(): SubscriptionExtractor? -    @Nullable-    @Throws(ExtractionException::class)-    open fun getFeedExtractor(url: String): FeedExtractor? = null-     @Throws(ExtractionException::class)     abstract fun getKioskList(): KioskList 
youpipe/extractor/src/main/kotlin/org/schabi/newpipe/extractor/feed/FeedExtractor.kt
diff --git a/youpipe/extractor/src/main/kotlin/org/schabi/newpipe/extractor/feed/FeedExtractor.kt b/youpipe/extractor/src/main/kotlin/org/schabi/newpipe/extractor/feed/FeedExtractor.ktdeleted file mode 100644index 32542c8257..0000000000--- a/youpipe/extractor/src/main/kotlin/org/schabi/newpipe/extractor/feed/FeedExtractor.kt+++ /dev/null@@ -1,16 +0,0 @@-package org.schabi.newpipe.extractor.feed--import org.schabi.newpipe.extractor.ListExtractor-import org.schabi.newpipe.extractor.StreamingService-import org.schabi.newpipe.extractor.linkhandler.ListLinkHandler-import org.schabi.newpipe.extractor.stream.StreamInfoItem--/**- * This class helps to extract items from lightweight feeds that the services may provide.- *- * YouTube is an example of a service that has this alternative available.- */-abstract class FeedExtractor(-    service: StreamingService,-    listLinkHandler: ListLinkHandler-) : ListExtractor<StreamInfoItem>(service, listLinkHandler)
youpipe/extractor/src/main/kotlin/org/schabi/newpipe/extractor/feed/FeedInfo.kt
diff --git a/youpipe/extractor/src/main/kotlin/org/schabi/newpipe/extractor/feed/FeedInfo.kt b/youpipe/extractor/src/main/kotlin/org/schabi/newpipe/extractor/feed/FeedInfo.ktdeleted file mode 100644index 53d74a9b5f..0000000000--- a/youpipe/extractor/src/main/kotlin/org/schabi/newpipe/extractor/feed/FeedInfo.kt+++ /dev/null@@ -1,73 +0,0 @@-package org.schabi.newpipe.extractor.feed--import org.schabi.newpipe.extractor.ListExtractor.InfoItemsPage-import org.schabi.newpipe.extractor.ListInfo-import org.schabi.newpipe.extractor.NewPipe-import org.schabi.newpipe.extractor.StreamingService-import org.schabi.newpipe.extractor.exceptions.ExtractionException-import org.schabi.newpipe.extractor.stream.StreamInfoItem-import org.schabi.newpipe.extractor.utils.ExtractorHelper-import java.io.IOException--open class FeedInfo(-    serviceId: Int,-    id: String,-    url: String,-    originalUrl: String,-    name: String,-    contentFilter: List<String>?,-    sortFilter: String?-) : ListInfo<StreamInfoItem>(-    serviceId,-    id,-    url,-    originalUrl,-    name,-    contentFilter ?: emptyList(),-    sortFilter ?: ""-) {--    companion object {-        @JvmStatic-        @Throws(IOException::class, ExtractionException::class)-        fun getInfo(url: String): FeedInfo {-            return getInfo(NewPipe.getServiceByUrl(url), url)-        }--        @JvmStatic-        @Throws(IOException::class, ExtractionException::class)-        fun getInfo(service: StreamingService, url: String): FeedInfo {-            val extractor = service.getFeedExtractor(url)-                ?: throw IllegalArgumentException(-                    "Service \"${service.serviceInfo.name}\" doesn't support FeedExtractor."-                )--            extractor.fetchPage()-            return getInfo(extractor)-        }--        @JvmStatic-        @Throws(IOException::class, ExtractionException::class)-        fun getInfo(extractor: FeedExtractor): FeedInfo {-            extractor.fetchPage()--            val serviceId = extractor.getServiceId()-            val id = extractor.getId()-            val url = extractor.getUrl()-            val originalUrl = extractor.getOriginalUrl()-            val name = extractor.getName()--            val info = FeedInfo(serviceId, id, url, originalUrl, name, null, null)--            val itemsPage: InfoItemsPage<StreamInfoItem> =-                ExtractorHelper.getItemsPageOrLogError(info, extractor)-            info.relatedItems = itemsPage.getItems()-            val nextPage = itemsPage.nextPage-            if (nextPage != null) {-                info.setNextPage(nextPage)-            }--            return info-        }-    }-}
youpipe/extractor/src/main/kotlin/org/schabi/newpipe/extractor/services/youtube/YoutubeDescriptionHelper.kt
diff --git a/youpipe/extractor/src/main/kotlin/org/schabi/newpipe/extractor/services/youtube/YoutubeDescriptionHelper.kt b/youpipe/extractor/src/main/kotlin/org/schabi/newpipe/extractor/services/youtube/YoutubeDescriptionHelper.ktindex a19b336d75..4edd47759b 100644--- a/youpipe/extractor/src/main/kotlin/org/schabi/newpipe/extractor/services/youtube/YoutubeDescriptionHelper.kt+++ b/youpipe/extractor/src/main/kotlin/org/schabi/newpipe/extractor/services/youtube/YoutubeDescriptionHelper.kt@@ -2,10 +2,10 @@ package org.schabi.newpipe.extractor.services.youtube  import kotlinx.serialization.json.JsonObject import kotlinx.serialization.json.JsonPrimitive-import org.jsoup.nodes.Entities import org.schabi.newpipe.extractor.services.youtube.YoutubeParsingHelper.getUrlFromNavigationEndpoint import org.schabi.newpipe.extractor.services.youtube.YoutubeParsingHelper.isYoutubeServiceURL import org.schabi.newpipe.extractor.services.youtube.YoutubeParsingHelper.isYoutubeURL+import org.schabi.newpipe.extractor.utils.Utils.escapeHtml import org.schabi.newpipe.extractor.utils.getArray import org.schabi.newpipe.extractor.utils.getBoolean import org.schabi.newpipe.extractor.utils.getObject@@ -83,7 +83,7 @@ object YoutubeDescriptionHelper {                 closers[closersIndex].pos             } -            textBuilder.append(Entities.escape(content.substring(currentTextPos, minPos)))+            textBuilder.append(escapeHtml(content.substring(currentTextPos, minPos)))             currentTextPos = minPos              if (closers[closersIndex].pos == minPos) {@@ -121,7 +121,7 @@ object YoutubeDescriptionHelper {             }         } -        textBuilder.append(Entities.escape(content.substring(currentTextPos)))+        textBuilder.append(escapeHtml(content.substring(currentTextPos)))          return textBuilder.toString()             .replace("\n", "<br>")@@ -152,7 +152,7 @@ object YoutubeDescriptionHelper {                 false             } -            val open = "<a href=\"${Entities.escape(url)}\">"+            val open = "<a href=\"${escapeHtml(url)}\">"             val transformContent = getTransformContentFun(run, isYoutubeUrl)              openers.add(Run(open, LINK_CLOSE, startIndex, transformContent))
youpipe/extractor/src/main/kotlin/org/schabi/newpipe/extractor/services/youtube/YoutubeParsingHelper.kt
diff --git a/youpipe/extractor/src/main/kotlin/org/schabi/newpipe/extractor/services/youtube/YoutubeParsingHelper.kt b/youpipe/extractor/src/main/kotlin/org/schabi/newpipe/extractor/services/youtube/YoutubeParsingHelper.ktindex fa88ee7464..63e4e64b81 100644--- a/youpipe/extractor/src/main/kotlin/org/schabi/newpipe/extractor/services/youtube/YoutubeParsingHelper.kt+++ b/youpipe/extractor/src/main/kotlin/org/schabi/newpipe/extractor/services/youtube/YoutubeParsingHelper.kt@@ -19,7 +19,6 @@ import kotlinx.serialization.json.jsonObject import kotlinx.serialization.json.put import kotlinx.serialization.json.putJsonArray import kotlinx.serialization.json.putJsonObject-import org.jsoup.nodes.Entities import org.schabi.newpipe.extractor.Image import org.schabi.newpipe.extractor.downloader.Response import org.schabi.newpipe.extractor.exceptions.AccountTerminatedException@@ -51,6 +50,7 @@ import org.schabi.newpipe.extractor.utils.RandomStringFromAlphabetGenerator import org.schabi.newpipe.extractor.utils.Utils import org.schabi.newpipe.extractor.utils.Utils.HTTP import org.schabi.newpipe.extractor.utils.Utils.HTTPS+import org.schabi.newpipe.extractor.utils.Utils.escapeHtml import org.schabi.newpipe.extractor.utils.Utils.getStringResultFromRegexArray import org.schabi.newpipe.extractor.utils.Utils.isNullOrEmpty import org.schabi.newpipe.extractor.utils.getArray@@ -755,8 +755,8 @@ object YoutubeParsingHelper {                     if (nav != null) {                         val url = getUrlFromNavigationEndpoint(nav)                         if (!isNullOrEmpty(url)) {-                            text = "<a href=\"" + Entities.escape(url!!) + "\">" +-                                    Entities.escape(text) + "</a>"+                            text = "<a href=\"" + escapeHtml(url!!) + "\">" ++                                    escapeHtml(text) + "</a>"                         }                     }                 }
youpipe/extractor/src/main/kotlin/org/schabi/newpipe/extractor/services/youtube/YoutubeService.kt
diff --git a/youpipe/extractor/src/main/kotlin/org/schabi/newpipe/extractor/services/youtube/YoutubeService.kt b/youpipe/extractor/src/main/kotlin/org/schabi/newpipe/extractor/services/youtube/YoutubeService.ktindex 14a6fd5103..1cec5ce59d 100644--- a/youpipe/extractor/src/main/kotlin/org/schabi/newpipe/extractor/services/youtube/YoutubeService.kt+++ b/youpipe/extractor/src/main/kotlin/org/schabi/newpipe/extractor/services/youtube/YoutubeService.kt@@ -5,7 +5,6 @@ import org.schabi.newpipe.extractor.channel.ChannelExtractor import org.schabi.newpipe.extractor.channel.tabs.ChannelTabExtractor import org.schabi.newpipe.extractor.comments.CommentsExtractor import org.schabi.newpipe.extractor.exceptions.ExtractionException-import org.schabi.newpipe.extractor.feed.FeedExtractor import org.schabi.newpipe.extractor.kiosk.KioskList import org.schabi.newpipe.extractor.linkhandler.LinkHandler import org.schabi.newpipe.extractor.linkhandler.LinkHandlerFactory@@ -21,7 +20,6 @@ import org.schabi.newpipe.extractor.search.SearchExtractor import org.schabi.newpipe.extractor.services.youtube.extractors.YoutubeChannelExtractor import org.schabi.newpipe.extractor.services.youtube.extractors.YoutubeChannelTabExtractor import org.schabi.newpipe.extractor.services.youtube.extractors.YoutubeCommentsExtractor-import org.schabi.newpipe.extractor.services.youtube.extractors.YoutubeFeedExtractor import org.schabi.newpipe.extractor.services.youtube.extractors.YoutubeMixPlaylistExtractor import org.schabi.newpipe.extractor.services.youtube.extractors.YoutubeMusicSearchExtractor import org.schabi.newpipe.extractor.services.youtube.extractors.YoutubePlaylistExtractor@@ -205,11 +203,6 @@ class YoutubeService(id: Int) : StreamingService(     override fun getSubscriptionExtractor(): SubscriptionExtractor =         YoutubeSubscriptionExtractor(this) -    @Throws(ExtractionException::class)-    override fun getFeedExtractor(channelUrl: String): FeedExtractor {-        return YoutubeFeedExtractor(this, getChannelLHFactory().fromUrl(channelUrl))-    }-     override fun getCommentsLHFactory(): ListLinkHandlerFactory =         YoutubeCommentsLinkHandlerFactory.getInstance() 
youpipe/extractor/src/main/kotlin/org/schabi/newpipe/extractor/services/youtube/extractors/YoutubeFeedExtractor.kt
diff --git a/youpipe/extractor/src/main/kotlin/org/schabi/newpipe/extractor/services/youtube/extractors/YoutubeFeedExtractor.kt b/youpipe/extractor/src/main/kotlin/org/schabi/newpipe/extractor/services/youtube/extractors/YoutubeFeedExtractor.ktdeleted file mode 100644index e6a9bcc3a0..0000000000--- a/youpipe/extractor/src/main/kotlin/org/schabi/newpipe/extractor/services/youtube/extractors/YoutubeFeedExtractor.kt+++ /dev/null@@ -1,86 +0,0 @@-package org.schabi.newpipe.extractor.services.youtube.extractors--import org.jsoup.Jsoup-import org.jsoup.nodes.Document-import org.schabi.newpipe.extractor.ListExtractor-import org.schabi.newpipe.extractor.Page-import org.schabi.newpipe.extractor.StreamingService-import org.schabi.newpipe.extractor.downloader.Downloader-import org.schabi.newpipe.extractor.exceptions.ContentNotAvailableException-import org.schabi.newpipe.extractor.exceptions.ExtractionException-import org.schabi.newpipe.extractor.feed.FeedExtractor-import org.schabi.newpipe.extractor.linkhandler.ListLinkHandler-import org.schabi.newpipe.extractor.services.youtube.YoutubeParsingHelper-import org.schabi.newpipe.extractor.stream.StreamInfoItem-import org.schabi.newpipe.extractor.stream.StreamInfoItemsCollector-import java.io.IOException--class YoutubeFeedExtractor(-    service: StreamingService,-    linkHandler: ListLinkHandler-) : FeedExtractor(service, linkHandler) {--    private var document: Document? = null--    @Throws(IOException::class, ExtractionException::class)-    override fun onFetchPage(downloader: Downloader) {-        val channelIdOrUser = linkHandler.id-        val feedUrl = YoutubeParsingHelper.getFeedUrlFrom(channelIdOrUser)--        val response = downloader.get(feedUrl)-        if (response.responseCode() == 404) {-            throw ContentNotAvailableException("Could not get feed: 404 - not found")-        }-        document = Jsoup.parse(response.responseBody())-    }--    override fun getInitialPage(): ListExtractor.InfoItemsPage<StreamInfoItem> {-        val entries = document!!.select("feed > entry")-        val collector = StreamInfoItemsCollector(getServiceId())--        for (entryElement in entries) {-            collector.commit(YoutubeFeedInfoItemExtractor(entryElement))-        }--        return ListExtractor.InfoItemsPage(collector, null)-    }--    override fun getId(): String {-        return getUrl().replace(WEBSITE_CHANNEL_BASE_URL, "")-    }--    override fun getUrl(): String {-        val authorUriElement = document!!.select("feed > author > uri")-            .first()-        if (authorUriElement != null) {-            val authorUriElementText = authorUriElement.text()-            if (authorUriElementText != "") {-                return authorUriElementText-            }-        }--        val linkElement = document!!.select("feed > link[rel*=alternate]")-            .first()-        if (linkElement != null) {-            return linkElement.attr("href")-        }--        return ""-    }--    override fun getName(): String {-        val nameElement = document!!.select("feed > author > name")-            .first()-            ?: return ""--        return nameElement.text()-    }--    override fun getPage(page: Page): ListExtractor.InfoItemsPage<StreamInfoItem> {-        return ListExtractor.InfoItemsPage.emptyPage()-    }--    companion object {-        private const val WEBSITE_CHANNEL_BASE_URL = "https://www.youtube.com/channel/"-    }-}
youpipe/extractor/src/main/kotlin/org/schabi/newpipe/extractor/services/youtube/extractors/YoutubeFeedInfoItemExtractor.kt
diff --git a/youpipe/extractor/src/main/kotlin/org/schabi/newpipe/extractor/services/youtube/extractors/YoutubeFeedInfoItemExtractor.kt b/youpipe/extractor/src/main/kotlin/org/schabi/newpipe/extractor/services/youtube/extractors/YoutubeFeedInfoItemExtractor.ktdeleted file mode 100644index 3747c1804b..0000000000--- a/youpipe/extractor/src/main/kotlin/org/schabi/newpipe/extractor/services/youtube/extractors/YoutubeFeedInfoItemExtractor.kt+++ /dev/null@@ -1,88 +0,0 @@-package org.schabi.newpipe.extractor.services.youtube.extractors--import org.jsoup.nodes.Element-import org.schabi.newpipe.extractor.Image-import org.schabi.newpipe.extractor.exceptions.ParsingException-import org.schabi.newpipe.extractor.localization.DateWrapper-import org.schabi.newpipe.extractor.stream.StreamInfoItemExtractor-import org.schabi.newpipe.extractor.stream.StreamType--class YoutubeFeedInfoItemExtractor(-    private val entryElement: Element-) : StreamInfoItemExtractor {--    override fun getStreamType(): StreamType = StreamType.VIDEO_STREAM--    override fun isAd(): Boolean = false--    override fun getDuration(): Long = -1--    override fun getViewCount(): Long {-        return entryElement.getElementsByTag("media:statistics").first()!!-            .attr("views").toLong()-    }--    override fun getUploaderName(): String? {-        return entryElement.select("author > name").first()!!.text()-    }--    override fun getUploaderUrl(): String? {-        return entryElement.select("author > uri").first()!!.text()-    }--    override fun isUploaderVerified(): Boolean = false--    override fun getTextualUploadDate(): String? {-        return entryElement.getElementsByTag("published").first()!!.text()-    }--    @Throws(ParsingException::class)-    override fun getUploadDate(): DateWrapper? {-        return DateWrapper.fromOffsetDateTime(getTextualUploadDate())-    }--    override fun getName(): String {-        return entryElement.getElementsByTag("title").first()!!.text()-    }--    override fun getUrl(): String {-        return entryElement.getElementsByTag("link").first()!!.attr("href")-    }--    override fun getThumbnails(): List<Image> {-        val thumbnailElement = entryElement.getElementsByTag("media:thumbnail").first()-            ?: return emptyList()--        val feedThumbnailUrl = thumbnailElement.attr("url")--        if (feedThumbnailUrl.isEmpty()) {-            return emptyList()-        }--        val newFeedThumbnailUrl = feedThumbnailUrl.replace("hqdefault", "mqdefault")--        val height: Int-        val width: Int--        if (newFeedThumbnailUrl == feedThumbnailUrl) {-            height = try {-                thumbnailElement.attr("height").toInt()-            } catch (e: NumberFormatException) {-                Image.HEIGHT_UNKNOWN-            }--            width = try {-                thumbnailElement.attr("width").toInt()-            } catch (e: NumberFormatException) {-                Image.WIDTH_UNKNOWN-            }-        } else {-            height = 320-            width = 180-        }--        return listOf(-            Image(newFeedThumbnailUrl, height, width, Image.ResolutionLevel.fromHeight(height))-        )-    }-}
youpipe/extractor/src/main/kotlin/org/schabi/newpipe/extractor/utils/JsonUtils.kt
diff --git a/youpipe/extractor/src/main/kotlin/org/schabi/newpipe/extractor/utils/JsonUtils.kt b/youpipe/extractor/src/main/kotlin/org/schabi/newpipe/extractor/utils/JsonUtils.ktindex 2cf55a6075..b36fac7362 100644--- a/youpipe/extractor/src/main/kotlin/org/schabi/newpipe/extractor/utils/JsonUtils.kt+++ b/youpipe/extractor/src/main/kotlin/org/schabi/newpipe/extractor/utils/JsonUtils.kt@@ -12,7 +12,6 @@ import kotlinx.serialization.json.jsonArray import kotlinx.serialization.json.jsonObject import kotlinx.serialization.json.jsonPrimitive import kotlinx.serialization.json.longOrNull-import org.jsoup.Jsoup import org.schabi.newpipe.extractor.exceptions.ParsingException import javax.annotation.Nonnull import javax.annotation.Nullable@@ -149,45 +148,6 @@ object JsonUtils {         }     } -    /**-     * Get an attribute of a web page as JSON.-     *-     * Originally a part of bandcampDirect.-     *-     * Example HTML:-     * ```-     * <p data-town="{"name":"Mycenae","country":"Greece"}">-     * This is Sparta!</p>-     * ```-     * Calling this function to get the attribute `data-town` returns the JsonObject for-     * ```-     * {-     *   "name": "Mycenae",-     *   "country": "Greece"-     * }-     * ```-     *-     * @param html     The HTML where the JSON we're looking for is stored-     * @param variable Name of the variable / attribute-     * @return The JsonObject stored in the variable with this name-     */-    @JvmStatic-    @Throws(ParsingException::class)-    fun getJsonData(html: String, variable: String): JsonObject {-        try {-            val document = Jsoup.parse(html)-            val json = document.getElementsByAttribute(variable).attr(variable)-            if (json.isBlank()) {-                throw ParsingException("Unable to get JSON data for variable $variable")-            }-            return jsonParser.parseToJsonElement(json).jsonObject-        } catch (e: ParsingException) {-            throw e-        } catch (e: Exception) {-            throw ParsingException("Could not parse JSON data for variable $variable", e)-        }-    }-     @JvmStatic     fun getStringListFromJsonArray(array: JsonArray): List<String> {         return array.mapNotNull { element ->
youpipe/extractor/src/main/kotlin/org/schabi/newpipe/extractor/utils/Utils.kt
diff --git a/youpipe/extractor/src/main/kotlin/org/schabi/newpipe/extractor/utils/Utils.kt b/youpipe/extractor/src/main/kotlin/org/schabi/newpipe/extractor/utils/Utils.ktindex d519c2bc9c..cdc8f836e4 100644--- a/youpipe/extractor/src/main/kotlin/org/schabi/newpipe/extractor/utils/Utils.kt+++ b/youpipe/extractor/src/main/kotlin/org/schabi/newpipe/extractor/utils/Utils.kt@@ -34,6 +34,27 @@ object Utils {     @JvmStatic     fun decodeUrlUtf8(url: String): String = URLDecoder.decode(url, Charsets.UTF_8) +    /**+     * Escape text for embedding in HTML, as element content or inside a double-quoted+     * attribute value.+     */+    @JvmStatic+    fun escapeHtml(text: String): String {+        val out = StringBuilder(text.length)+        for (c in text) {+            when (c) {+                '&' -> out.append("&amp;")+                '<' -> out.append("&lt;")+                '>' -> out.append("&gt;")+                '"' -> out.append("&quot;")+                '\'' -> out.append("&#39;")+                '\u00a0' -> out.append("&nbsp;")+                else -> out.append(c)+            }+        }+        return out.toString()+    }+     /**      * Remove all non-digit characters from a string.      *