From cac1ba9f418a981298b744cf69b10d1eaae2d4d7 Mon Sep 17 00:00:00 2001 From: Ivan Paramonau Date: Fri, 24 Jul 2026 11:07:26 -0400 Subject: [PATCH 1/2] oEmbed: fix UTF-8 encoding of XML responses --- lib/plugins/system/oembed/oembedUtils.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/plugins/system/oembed/oembedUtils.js b/lib/plugins/system/oembed/oembedUtils.js index 6e1ebf861..ab7ba055a 100644 --- a/lib/plugins/system/oembed/oembedUtils.js +++ b/lib/plugins/system/oembed/oembedUtils.js @@ -379,8 +379,10 @@ function xmlStream2oembed(stream, callback) { } else { if (prop) { - if (charset !== 'UTF-8') { - // Decode only non UTF-8 because sax makes decoding. + if (charset /* !== 'UTF-8' */) { // previouly - Decode only non UTF-8 because sax makes decoding. + // UTF-8 is not decoded by default in July 2026 + // Ex.: https://rutube.ru/video/bf4825090681c5c25312534bab3c7f62/ + var oldValue = value; value = encodeText(charset, value); // log(' -- decode oembed xml (charset, in, out):', charset, oldValue, value); From a209b6779b3c0b87505fc8b2d60c31ef70c9f708 Mon Sep 17 00:00:00 2001 From: Ivan Paramonau Date: Fri, 24 Jul 2026 11:26:56 -0400 Subject: [PATCH 2/2] Make sure JSON is the first choice for oEmbed when available --- lib/plugins/system/oembed/oembed.js | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/lib/plugins/system/oembed/oembed.js b/lib/plugins/system/oembed/oembed.js index 6e7d6c1ff..3d663e9c2 100644 --- a/lib/plugins/system/oembed/oembed.js +++ b/lib/plugins/system/oembed/oembed.js @@ -114,7 +114,15 @@ export default { getData: function(url, oembedLinks, oembedUtils, options, cb) { - var href = oembedLinks[0].href; + const weights = { + 'application/json+oembed': -1, + 'text/xml+oembed': 1 + } + + var href = oembedLinks.sort( + // Prefer JSON + (a,b) => a.type && b.type && (weights[a.type.toLowerCase()] - weights[b.type.toLowerCase()]) || 0 + )[0].href; var skip = CONFIG.SKIP_OEMBED_RE_LIST && CONFIG.SKIP_OEMBED_RE_LIST.some(re => re.test(href)),