escape referrerQuery in the oEmebed xml generator
This commit is contained in:
parent
3744f26295
commit
24cc07c09b
3 changed files with 17 additions and 12 deletions
|
@ -61,6 +61,17 @@ function getParameterByName(name, url) {
|
|||
return match && decodeURIComponent(match[1].replace(/\+/g, ' '));
|
||||
}
|
||||
|
||||
function escapeHtmlProperty(property) {
|
||||
return property
|
||||
? String(property)
|
||||
.replace(/&/g, '&')
|
||||
.replace(/</g, '<')
|
||||
.replace(/>/g, '>')
|
||||
.replace(/"/g, '"')
|
||||
.replace(/'/g, ''')
|
||||
: '';
|
||||
}
|
||||
|
||||
// module.exports needed since the web server imports this function
|
||||
module.exports = {
|
||||
CONTINENT_COOKIE,
|
||||
|
@ -71,4 +82,5 @@ module.exports = {
|
|||
generateStreamUrl,
|
||||
getParameterByName,
|
||||
getThumbnailCdnUrl,
|
||||
escapeHtmlProperty,
|
||||
};
|
||||
|
|
|
@ -18,6 +18,7 @@ const {
|
|||
generateStreamUrl,
|
||||
getParameterByName,
|
||||
getThumbnailCdnUrl,
|
||||
escapeHtmlProperty,
|
||||
} = require('../../ui/util/web');
|
||||
const { getJsBundleId } = require('../bundle-id.js');
|
||||
const { lbryProxy: Lbry } = require('../lbry');
|
||||
|
@ -54,17 +55,6 @@ function truncateDescription(description, maxChars = 200) {
|
|||
return chars.length > maxChars ? truncated + '...' : truncated;
|
||||
}
|
||||
|
||||
function escapeHtmlProperty(property) {
|
||||
return property
|
||||
? String(property)
|
||||
.replace(/&/g, '&')
|
||||
.replace(/</g, '<')
|
||||
.replace(/>/g, '>')
|
||||
.replace(/"/g, '"')
|
||||
.replace(/'/g, ''')
|
||||
: '';
|
||||
}
|
||||
|
||||
function getCategoryMeta(path) {
|
||||
const page = Object.keys(CATEGORY_METADATA).find((x) => path === `/$/${x}` || path === `/$/${x}/`);
|
||||
return CATEGORY_METADATA[page];
|
||||
|
|
|
@ -5,6 +5,7 @@ const {
|
|||
generateEmbedUrl,
|
||||
getParameterByName,
|
||||
getThumbnailCdnUrl,
|
||||
escapeHtmlProperty,
|
||||
} = require('../../ui/util/web');
|
||||
const { lbryProxy: Lbry } = require('../lbry');
|
||||
|
||||
|
@ -52,7 +53,9 @@ function generateOEmbedData(claim, referrerQuery) {
|
|||
const authorUrlPath = authorClaim && authorClaim.canonical_url.replace('lbry://', '').replace('#', ':');
|
||||
const authorUrl = authorClaim ? `${URL}/${authorUrlPath}` : null;
|
||||
const thumbnailUrl = value && value.thumbnail && value.thumbnail.url && getThumbnailCdnUrl(value.thumbnail.url);
|
||||
const videoUrl = generateEmbedUrl(claim.name, claim.claim_id) + (referrerQuery ? `r=${referrerQuery}` : '');
|
||||
const videoUrl =
|
||||
generateEmbedUrl(claim.name, claim.claim_id) +
|
||||
(referrerQuery ? `r=${encodeURIComponent(escapeHtmlProperty(referrerQuery))}` : '');
|
||||
|
||||
const { html, width, height } = generateEmbedIframeData(videoUrl);
|
||||
|
||||
|
|
Loading…
Reference in a new issue