fedimbed.bluesky: sanitize markdown

This commit is contained in:
Cynthia Foxwell 2025-04-20 21:49:52 -06:00
parent efcd4fbe7b
commit 3a5c4f6b10
Signed by: Cynosphere
SSH key fingerprint: SHA256:H3SM8ufP/uxqLwKSH7xY89TDnbR9uOHzjLoBr0tlajk

View file

@ -360,6 +360,12 @@ async function blueskyQuoteEmbed(quote) {
const components = []; const components = [];
let content = quote.value.text;
if (quote.value.facets?.length > 0) {
content = processBlueskyFacets(content, quote.value.facets);
}
content = content.replaceAll("`", "\u02cb").replaceAll("*", "\u2217").replaceAll("||", "|\u200b|");
const header = [ const header = [
{ {
type: 10, type: 10,
@ -370,13 +376,7 @@ async function blueskyQuoteEmbed(quote) {
components: [ components: [
{ {
type: 10, type: 10,
content: `## ${quote.author.displayName}\n-# [@${quote.author.handle}](https://bsky.app/profile/${ content: `## ${quote.author.displayName}\n-# [@${quote.author.handle}](https://bsky.app/profile/${quote.author.did})\n${content}`,
quote.author.did
})\n${
quote.value.facets?.length ?? 0 > 0
? processBlueskyFacets(quote.value.text, quote.value.facets)
: quote.value.text
}`,
}, },
], ],
accessory: { accessory: {
@ -648,6 +648,12 @@ async function bluesky(msg, url, spoiler = false) {
})](https://bsky.app/profile/${reply.author.did}/post/${reply.uri.substring(reply.uri.lastIndexOf("/") + 1)})`; })](https://bsky.app/profile/${reply.author.did}/post/${reply.uri.substring(reply.uri.lastIndexOf("/") + 1)})`;
} }
let content = post.record.text;
if (post.record.facets?.length > 0) {
content = processBlueskyFacets(content, post.record.facets);
}
content = content.replaceAll("`", "\u02cb").replaceAll("*", "\u2217").replaceAll("||", "|\u200b|");
const header = [ const header = [
context && { context && {
type: 10, type: 10,
@ -658,13 +664,7 @@ async function bluesky(msg, url, spoiler = false) {
components: [ components: [
{ {
type: 10, type: 10,
content: `## ${post.author.displayName}\n-# [@${post.author.handle}](https://bsky.app/profile/${ content: `## ${post.author.displayName}\n-# [@${post.author.handle}](https://bsky.app/profile/${post.author.did})\n${content}`,
post.author.did
})\n${
post.record.facets?.length ?? 0 > 0
? processBlueskyFacets(post.record.text, post.record.facets)
: post.record.text
}`,
}, },
], ],
accessory: { accessory: {