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)), 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);