Skip to content
Merged
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ rebuilds it: only `footer div nav section aside header p span small strong em b
br hr h2-h6` survive; attributes are limited to `class title role lang dir aria-* data-pfs-*`
plus `href rel target hreflang` on `a` and `src alt width height loading decoding` on `img`;
every value is entity-decoded, checked and re-escaped, so what was checked is what the browser
sees; `href` accepts `http:`, `https:`, `mailto:`, `tel:` or relative URLs; `src` accepts
sees; `href` accepts `http:`, `https:`, `mailto:`, `tel:`, `sms:` or relative URLs; `src` accepts
`http:`, `https:`, `mailto:` or relative URLs, after decoding and removing control characters.
Comments, unknown tags (text kept, escaped), and `script`/`style`/`iframe`/
`svg`/`math`/`noscript`/`template`/... with their contents are dropped. The only `<style>` and
Expand Down
2 changes: 1 addition & 1 deletion index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -115,5 +115,5 @@ export declare function escapeHtml(value: unknown): string;
export declare function sanitizeTemplate(html: string): string;
export declare function sanitizeHtml(html: string, opts?: { styleToken?: string; textTokens?: string[] }): string;
export declare function sanitizeCss(css: string): string;
/** http(s), mailto or relative URL, normalized; null when anything else. */
/** http(s), mailto, tel, sms or relative URL, normalized; null when anything else. */
export declare function safeUrl(url: string): string | null;
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@profullstack/footer",
"version": "0.7.2",
"version": "0.7.3",
"type": "module",
"description": "Profullstack's distributed footer engine for remote, agent-friendly site branding and navigation.",
"keywords": ["footer", "webring", "openwebring", "copyright", "react", "nextjs", "hono", "ssr"],
Expand Down
4 changes: 2 additions & 2 deletions src/render.js
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ const TAG_ATTRS = {
img: new Set(['src', 'alt', 'width', 'height', 'loading', 'decoding']),
};
const URL_ATTRS = new Set(['href', 'src']);
const URL_SCHEMES = new Set(['http', 'https', 'mailto', 'tel']);
const URL_SCHEMES = new Set(['http', 'https', 'mailto', 'tel', 'sms']);
/** @type {Record<string, RegExp>} */
const ATTR_VALUES = {
target: /^(_blank|_self|_parent|_top)$/i,
Expand Down Expand Up @@ -398,7 +398,7 @@ export function sanitizeHtml(html, opts = {}) {
let v = stripTokens(decodeEntities(raw));
if (URL_ATTRS.has(k)) {
const u = safeUrl(v);
if (u === null || (k === 'src' && /^tel:/i.test(u))) continue;
if (u === null || (k === 'src' && /^(tel|sms):/i.test(u))) continue;
v = u;
}
if (ATTR_VALUES[k] && !ATTR_VALUES[k].test(v)) continue;
Expand Down
4 changes: 2 additions & 2 deletions src/template.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
// render.js does not fill; older installs then keep their bundled template.

export default {
version: '0.7.2',
version: '0.7.3',
renderer: 1,
css: [
'.pfs-footer{--pfs-footer-muted:color-mix(in srgb,currentColor 62%,transparent);--pfs-footer-gap:.5rem 1.25rem;--pfs-footer-size:.875rem;',
Expand Down Expand Up @@ -86,7 +86,7 @@ export default {
'<a class="pfs-footer__badge pfs-footer__badge--directory" href="https://aiagentsdirectory.com/agent/profullstack" rel="noopener" title="Discover Profullstack on AI Agents Directory"><img src="https://aiagentsdirectory.com/featured-badge.svg?v=2024" alt="Profullstack - Featured on AI Agents Directory" width="200" height="50" loading="lazy"></a>',
'<a class="pfs-footer__badge pfs-footer__badge--directory" href="https://nextbigproduct.com/product/profullstack" rel="noopener"><img src="https://nextbigproduct.com/assets/badge/profullstack.svg?theme=light" alt="Featured on NextBigProduct" width="250" height="54" loading="lazy"></a>',
'</div>',
'<p class="pfs-footer__copy"><a href="tel:+18885264640">Phone: +1-888-526-4640</a></p>',
'<p class="pfs-footer__copy pfs-footer__contact"><a href="tel:+18885264640">Call +1-888-526-4640</a> &middot; <a href="sms:+19166599471">Text +1-916-659-9471</a></p>',
'<p class="pfs-footer__copy">&copy; {{years}} <a class="pfs-footer__brand" href="https://profullstack.com/" title="Profullstack, Inc."><img src="https://profullstack.com/assets/logo.svg" alt="" width="20" height="11" loading="lazy"></a> <a href="{{owner_url}}">{{owner_name}}</a>{{#tagline}} <span class="pfs-footer__tagline">&middot; {{tagline}}</span>{{/tagline}}</p>',
'</div>',
'</footer>',
Expand Down
4 changes: 2 additions & 2 deletions template.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
{
"version": "0.7.2",
"version": "0.7.3",
"renderer": 1,
"css": ".pfs-footer{--pfs-footer-muted:color-mix(in srgb,currentColor 62%,transparent);--pfs-footer-gap:.5rem 1.25rem;--pfs-footer-size:.875rem;border-top:1px solid color-mix(in srgb,currentColor 14%,transparent);font-size:var(--pfs-footer-size);line-height:1.5;color:inherit}html:has([data-pfs-footer]) [data-pit-footer],html:has([data-profullstack-footer]) [data-pit-footer],html:has([data-pfs-footer]) [data-net-footer],html:has([data-profullstack-footer]) [data-net-footer],html:has([data-pfs-footer]) footer:not([data-pfs-footer]):not([data-profullstack-footer]),html:has([data-profullstack-footer]) footer:not([data-pfs-footer]):not([data-profullstack-footer]){display:none!important}.pfs-footer__inner{max-width:72rem;margin:0 auto;padding:.85rem 1rem;display:flex;flex-direction:column;align-items:center;gap:.4rem;text-align:center}.pfs-footer a{color:var(--pfs-footer-muted);text-decoration:none}.pfs-footer a:hover,.pfs-footer a:focus-visible{color:inherit;text-decoration:underline}.pfs-footer__links{display:flex;flex-wrap:wrap;justify-content:center;gap:.35rem 1rem}.pfs-footer__ring{display:flex;flex-wrap:wrap;justify-content:center;align-items:center;gap:.4rem}.pfs-footer__badges{display:flex;flex-wrap:wrap;justify-content:center;align-items:center;gap:.4rem}.pfs-footer__badges:has(.pfs-footer__badge--publisher:not(.pfs-footer__badge--default)[href*=\"pwamart.com\"]) .pfs-footer__badge--default[href^=\"https://pwamart.com/\"],.pfs-footer__badges:has(.pfs-footer__badge--publisher:not(.pfs-footer__badge--default)[href*=\"built.indie\"]) .pfs-footer__badge--default[href^=\"https://built.indie.pit.world/\"]{display:none!important}.pfs-footer a.pfs-footer__badge{display:inline-block;line-height:0}.pfs-footer__badge img{display:block;width:200px;height:44px;max-width:100%}.pfs-footer__badge--site img{width:auto;height:auto}.pfs-footer__badge--publisher img{width:32px;height:32px;max-width:none;object-fit:contain}.pfs-footer__badge--square img{width:32px;height:32px;max-width:none;object-fit:contain}.pfs-footer__badge--c0mpute img{width:136px;height:auto;aspect-ratio:170/36;max-width:none;opacity:.85}.pfs-footer__badge--c0mpute:hover img,.pfs-footer__badge--c0mpute:focus-visible img{opacity:1}.pfs-footer__directories{margin-top:.4rem}.pfs-footer__badge--directory img{width:auto;height:32px;max-width:none}.pfs-footer__news{display:flex;justify-content:center}.pfs-footer__sub{display:flex;align-items:center;gap:.35rem;margin:0;flex-wrap:wrap;justify-content:center}.pfs-footer__sub label{font:inherit;font-size:.8125rem;color:var(--pfs-footer-muted)}.pfs-footer__sub input[type=email]{box-sizing:border-box;appearance:none;font:inherit;font-size:.875rem;line-height:1.4;color:inherit;background:color-mix(in srgb,currentColor 8%,transparent);width:13.5rem;max-width:62vw;padding:.4rem .65rem;border:0;border-radius:.35rem}.pfs-footer__sub input[type=email]:hover{background:color-mix(in srgb,currentColor 11%,transparent)}.pfs-footer__sub input[type=email]::placeholder{color:var(--pfs-footer-muted);opacity:1}.pfs-footer__sub input[type=email]:focus-visible{outline:2px solid color-mix(in srgb,currentColor 58%,transparent);outline-offset:2px}.pfs-footer__sub button{font:inherit;font-size:.8125rem;color:var(--pfs-footer-muted);background:transparent;padding:.2rem .6rem;border:1px solid color-mix(in srgb,currentColor 25%,transparent);border-radius:.35rem;cursor:pointer}.pfs-footer__sub button:hover,.pfs-footer__sub button:focus-visible{color:inherit}.pfs-footer__hp{position:absolute!important;left:-9999px!important;width:1px;height:1px;opacity:0}.pfs-footer__sub+.pfs-footer__sublink{display:none}.pfs-footer__msg{flex-basis:100%;text-align:center;font-size:.8125rem;color:var(--pfs-footer-muted)}.pfs-footer__msg:empty{display:none}.pfs-footer__msg[data-state=ok]{color:inherit}.pfs-footer__msg[data-state=error]{color:#d92d20;color:light-dark(#b42318,#f97066)}.pfs-footer__copy{margin:0;color:var(--pfs-footer-muted)}.pfs-footer__copy a{color:inherit}.pfs-footer__tagline{display:inline-block;white-space:nowrap}.pfs-footer__brand{display:inline-flex;align-items:center;justify-content:center;vertical-align:middle;margin-inline:.35rem;padding:2px 4px;border-radius:3px;background:#202124;line-height:0}.pfs-footer__brand img{display:block;width:20px;height:11px;max-width:none}",
"link": "<a href=\"{{href}}\"{{#rel}} rel=\"{{rel}}\"{{/rel}}>{{label}}</a>",
"footer": "<footer class=\"pfs-footer\" data-pfs-footer=\"{{version}}\">{{#css}}<style{{#nonce}} nonce=\"{{nonce}}\"{{/nonce}}>{{{css}}}</style>{{/css}}<div class=\"pfs-footer__inner\">{{#links}}<nav class=\"pfs-footer__links\" aria-label=\"Footer\">{{{links}}}</nav>{{/links}}<nav class=\"pfs-footer__links\" aria-label=\"Profullstack products\"><a href=\"https://profullstack.com/stack/build\">Agentic site builder</a><a href=\"https://crawlproof.com/surveys\">CrawlProof Surveys</a></nav><nav class=\"webring pfs-footer__ring\" aria-label=\"{{ring_name}} webring\"><a href=\"{{previous}}\" rel=\"prev\" title=\"Previous site\">&lt;&lt;</a><a href=\"{{ring}}\">{{ring_name}}</a><a href=\"{{next}}\" rel=\"next\" title=\"Next site\">&gt;&gt;</a></nav><div class=\"pfs-footer__news\">{{{subscribe}}}<a class=\"pfs-footer__sublink\" href=\"https://pit.world/subscribe?site={{site}}\">Newsletter</a></div><div class=\"pfs-footer__badges\"><a class=\"pfs-footer__badge pfs-footer__badge--publisher pfs-footer__badge--default\" href=\"https://built.indie.pit.world/for?site={{site}}\"><img src=\"https://built.indie.pit.world/favicon.svg\" alt=\"Find this site on built.indie\" width=\"32\" height=\"32\" loading=\"lazy\"></a><a class=\"pfs-footer__badge pfs-footer__badge--publisher pfs-footer__badge--default\" href=\"https://pwamart.com/for?site={{site}}\"><img src=\"https://pwamart.com/icon.svg\" alt=\"Find this site on PwaMart\" width=\"32\" height=\"32\" loading=\"lazy\"></a><a class=\"pfs-footer__badge pfs-footer__badge--publisher pfs-footer__badge--default\" href=\"https://saasrow.pwa.pit.world/for?site={{site}}\"><img src=\"https://saasrow.pwa.pit.world/icon-192.png\" alt=\"Find this site on SaaSRow\" width=\"32\" height=\"32\" loading=\"lazy\"></a>{{{badges}}}</div><div class=\"pfs-footer__badges pfs-footer__directories\"><a class=\"pfs-footer__badge pfs-footer__badge--directory\" href=\"https://twelve.tools\" rel=\"noopener\"><img src=\"https://twelve.tools/badge0-white.svg\" alt=\"Featured on Twelve Tools\" width=\"148\" height=\"40\" loading=\"lazy\"></a><a class=\"pfs-footer__badge pfs-footer__badge--directory\" href=\"https://www.aidirectori.es/ai-tools/profullstack\" rel=\"noopener\"><img src=\"https://cdn.aidirectori.es/ai-tools/badges/light-mode.png\" alt=\"AI Directories Badge\" width=\"200\" height=\"46\" loading=\"lazy\"></a><a class=\"pfs-footer__badge pfs-footer__badge--directory\" href=\"https://aiagentsdirectory.com/agent/profullstack\" rel=\"noopener\" title=\"Discover Profullstack on AI Agents Directory\"><img src=\"https://aiagentsdirectory.com/featured-badge.svg?v=2024\" alt=\"Profullstack - Featured on AI Agents Directory\" width=\"200\" height=\"50\" loading=\"lazy\"></a><a class=\"pfs-footer__badge pfs-footer__badge--directory\" href=\"https://nextbigproduct.com/product/profullstack\" rel=\"noopener\"><img src=\"https://nextbigproduct.com/assets/badge/profullstack.svg?theme=light\" alt=\"Featured on NextBigProduct\" width=\"250\" height=\"54\" loading=\"lazy\"></a></div><p class=\"pfs-footer__copy\"><a href=\"tel:+18885264640\">Phone: +1-888-526-4640</a></p><p class=\"pfs-footer__copy\">&copy; {{years}} <a class=\"pfs-footer__brand\" href=\"https://profullstack.com/\" title=\"Profullstack, Inc.\"><img src=\"https://profullstack.com/assets/logo.svg\" alt=\"\" width=\"20\" height=\"11\" loading=\"lazy\"></a> <a href=\"{{owner_url}}\">{{owner_name}}</a>{{#tagline}} <span class=\"pfs-footer__tagline\">&middot; {{tagline}}</span>{{/tagline}}</p></div></footer>",
"footer": "<footer class=\"pfs-footer\" data-pfs-footer=\"{{version}}\">{{#css}}<style{{#nonce}} nonce=\"{{nonce}}\"{{/nonce}}>{{{css}}}</style>{{/css}}<div class=\"pfs-footer__inner\">{{#links}}<nav class=\"pfs-footer__links\" aria-label=\"Footer\">{{{links}}}</nav>{{/links}}<nav class=\"pfs-footer__links\" aria-label=\"Profullstack products\"><a href=\"https://profullstack.com/stack/build\">Agentic site builder</a><a href=\"https://crawlproof.com/surveys\">CrawlProof Surveys</a></nav><nav class=\"webring pfs-footer__ring\" aria-label=\"{{ring_name}} webring\"><a href=\"{{previous}}\" rel=\"prev\" title=\"Previous site\">&lt;&lt;</a><a href=\"{{ring}}\">{{ring_name}}</a><a href=\"{{next}}\" rel=\"next\" title=\"Next site\">&gt;&gt;</a></nav><div class=\"pfs-footer__news\">{{{subscribe}}}<a class=\"pfs-footer__sublink\" href=\"https://pit.world/subscribe?site={{site}}\">Newsletter</a></div><div class=\"pfs-footer__badges\"><a class=\"pfs-footer__badge pfs-footer__badge--publisher pfs-footer__badge--default\" href=\"https://built.indie.pit.world/for?site={{site}}\"><img src=\"https://built.indie.pit.world/favicon.svg\" alt=\"Find this site on built.indie\" width=\"32\" height=\"32\" loading=\"lazy\"></a><a class=\"pfs-footer__badge pfs-footer__badge--publisher pfs-footer__badge--default\" href=\"https://pwamart.com/for?site={{site}}\"><img src=\"https://pwamart.com/icon.svg\" alt=\"Find this site on PwaMart\" width=\"32\" height=\"32\" loading=\"lazy\"></a><a class=\"pfs-footer__badge pfs-footer__badge--publisher pfs-footer__badge--default\" href=\"https://saasrow.pwa.pit.world/for?site={{site}}\"><img src=\"https://saasrow.pwa.pit.world/icon-192.png\" alt=\"Find this site on SaaSRow\" width=\"32\" height=\"32\" loading=\"lazy\"></a>{{{badges}}}</div><div class=\"pfs-footer__badges pfs-footer__directories\"><a class=\"pfs-footer__badge pfs-footer__badge--directory\" href=\"https://twelve.tools\" rel=\"noopener\"><img src=\"https://twelve.tools/badge0-white.svg\" alt=\"Featured on Twelve Tools\" width=\"148\" height=\"40\" loading=\"lazy\"></a><a class=\"pfs-footer__badge pfs-footer__badge--directory\" href=\"https://www.aidirectori.es/ai-tools/profullstack\" rel=\"noopener\"><img src=\"https://cdn.aidirectori.es/ai-tools/badges/light-mode.png\" alt=\"AI Directories Badge\" width=\"200\" height=\"46\" loading=\"lazy\"></a><a class=\"pfs-footer__badge pfs-footer__badge--directory\" href=\"https://aiagentsdirectory.com/agent/profullstack\" rel=\"noopener\" title=\"Discover Profullstack on AI Agents Directory\"><img src=\"https://aiagentsdirectory.com/featured-badge.svg?v=2024\" alt=\"Profullstack - Featured on AI Agents Directory\" width=\"200\" height=\"50\" loading=\"lazy\"></a><a class=\"pfs-footer__badge pfs-footer__badge--directory\" href=\"https://nextbigproduct.com/product/profullstack\" rel=\"noopener\"><img src=\"https://nextbigproduct.com/assets/badge/profullstack.svg?theme=light\" alt=\"Featured on NextBigProduct\" width=\"250\" height=\"54\" loading=\"lazy\"></a></div><p class=\"pfs-footer__copy pfs-footer__contact\"><a href=\"tel:+18885264640\">Call +1-888-526-4640</a> &middot; <a href=\"sms:+19166599471\">Text +1-916-659-9471</a></p><p class=\"pfs-footer__copy\">&copy; {{years}} <a class=\"pfs-footer__brand\" href=\"https://profullstack.com/\" title=\"Profullstack, Inc.\"><img src=\"https://profullstack.com/assets/logo.svg\" alt=\"\" width=\"20\" height=\"11\" loading=\"lazy\"></a> <a href=\"{{owner_url}}\">{{owner_name}}</a>{{#tagline}} <span class=\"pfs-footer__tagline\">&middot; {{tagline}}</span>{{/tagline}}</p></div></footer>",
"houseLinks": [
{
"label": "Find a pro",
Expand Down
3 changes: 3 additions & 0 deletions test/sanitize.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,9 @@ test('javascript: urls in every disguise are dropped', () => {
test('safe urls survive and are re-escaped', () => {
assert.equal(sanitizeHtml('<a href="https://a.test/?a=1&amp;b=2">x</a>'), '<a href="https://a.test/?a=1&amp;b=2">x</a>');
assert.equal(sanitizeHtml('<a href="mailto:hi@a.test">x</a>'), '<a href="mailto:hi@a.test">x</a>');
assert.equal(sanitizeHtml('<a href="tel:+18885264640">x</a>'), '<a href="tel:+18885264640">x</a>');
assert.equal(sanitizeHtml('<a href="sms:+19166599471?body=hi">x</a>'), '<a href="sms:+19166599471?body=hi">x</a>');
assert.equal(sanitizeHtml('<img src="sms:+19166599471">'), '<img>');
assert.equal(sanitizeHtml('<a href="/p">x</a><a href="#top">y</a><a href="?q=1">z</a>'), '<a href="/p">x</a><a href="#top">y</a><a href="?q=1">z</a>');
assert.equal(safeUrl('/a:b'), '/a:b');
assert.equal(safeUrl(' https://a.test/ '), 'https://a.test/');
Expand Down
Loading