Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 16 additions & 4 deletions scripts/stellar_cli_plugins.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,31 @@ import https from "https";

// In case there are plugins to exclude from the list, add them here.
// E.g. "user/repo"
const excludePlugins = [];
const excludePlugins = ["haqnawaz03329-debug/haqnawaz"];

// GitHub repo descriptions are attacker-controlled (anyone can tag a repo with
// the `stellar-cli-plugin` topic), and this content is injected into MDX, which
// renders HTML/JSX. Neutralize characters that could execute as markup/script.
function sanitize(value) {
return (value || "")
.replace(/&/g, "&")
.replace(/</g, "&lt;")
.replace(/>/g, "&gt;")
.replace(/{/g, "&#123;")
.replace(/}/g, "&#125;");
}

function exportMDX(data) {
const pluginsContent = data.items.reduce((buffer, item) => {
if (excludePlugins.includes(item.full_name)) {
return buffer;
}

const plugin = `### [${item.full_name}](${item.html_url})
const plugin = `### [${sanitize(item.full_name)}](${encodeURI(item.html_url)})

${item.description || ""}
${sanitize(item.description)}

[${item.html_url}](${item.html_url})
[${encodeURI(item.html_url)}](${encodeURI(item.html_url)})
`;

return buffer + plugin;
Expand Down
Loading