GeezerVison is showing github.com — :bug: fix ssg · nullstack/nullstack@fbd2497
File treeExpand file treeCollapse file tree Open diff view settings Expand file treeCollapse file tree Open diff view settings Collapse file Copy file name to clipboardExpand all lines: builders/ssg.js +1-1Lines changed: 1 addition & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
@@ -39,7 +39,7 @@ module.exports = async function ssg({ output, cache, environment }) { | 39 | 39 | .find((line) => line.indexOf(stateLookup) > -1) | 40 | 40 | .split(stateLookup)[1] | 41 | 41 | .slice(0, -2) | 42 | | - const { instances, page } = JSON.parse(decodeURIComponent(state).replace(/<\\/g, '<')) | | 42 | + const { instances, page } = JSON.parse(decodeURIComponent(state)) | 43 | 43 |
| 44 | 44 | if (url !== `/nullstack/${application.environment.key}/offline` && url !== '/404') { | 45 | 45 | pages[url] = page | |
Collapse file Copy file name to clipboardExpand all lines: client/render.js +2-1Lines changed: 2 additions & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
| | 1 | +import { sanitizeInnerHtml } from '../shared/sanitizeString' | 1 | 2 | import generateTruthyString from '../shared/generateTruthyString' | 2 | 3 | import { isFalse, isText } from '../shared/nodes' | 3 | 4 | import { anchorableElement } from './anchorableNode' | @@ -28,7 +29,7 @@ export default function render(node, options) { | 28 | 29 | for (const name in node.attributes) { | 29 | 30 | if (name === 'debounce') continue | 30 | 31 | if (name === 'html') { | 31 | | - node.element.innerHTML = node.attributes[name] | | 32 | + node.element.innerHTML = sanitizeInnerHtml(node.attributes[name]) | 32 | 33 | node.head || anchorableElement(node.element) | 33 | 34 | } else if (name.startsWith('on')) { | 34 | 35 | if (node.attributes[name] !== undefined) { | |
Collapse file Copy file name to clipboardExpand all lines: client/rerender.js +2-1Lines changed: 2 additions & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
| | 1 | +import { sanitizeInnerHtml } from '../shared/sanitizeString' | 1 | 2 | import generateTruthyString from '../shared/generateTruthyString' | 2 | 3 | import { isFalse, isText, isUndefined } from '../shared/nodes' | 3 | 4 | import { anchorableElement } from './anchorableNode' | @@ -14,7 +15,7 @@ function updateAttributes(selector, currentAttributes, nextAttributes) { | 14 | 15 | reref(nextAttributes, selector) | 15 | 16 | } else if (name === 'html') { | 16 | 17 | if (nextAttributes[name] !== currentAttributes[name]) { | 17 | | - selector.innerHTML = nextAttributes[name] | | 18 | + selector.innerHTML = sanitizeInnerHtml(nextAttributes[name]) | 18 | 19 | anchorableElement(selector) | 19 | 20 | } | 20 | 21 | } else if (name === 'checked' || name === 'value') { | |
Collapse file Copy file name to clipboardExpand all lines: client/router.js +3-1Lines changed: 3 additions & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
@@ -6,6 +6,7 @@ import { updateParams } from './params' | 6 | 6 | import segments from './segments' | 7 | 7 | import windowEvent from './windowEvent' | 8 | 8 | import worker from './worker' | | 9 | +import deserialize from '../shared/deserialize' | 9 | 10 |
| 10 | 11 | let redirectTimer = null | 11 | 12 |
| @@ -40,7 +41,8 @@ class Router { | 40 | 41 | const endpoint = path === '/' ? api : path + api | 41 | 42 | try { | 42 | 43 | const response = await fetch(endpoint) | 43 | | - const payload = await response.json(url) | | 44 | + const meta = await response.text() | | 45 | + const payload = deserialize(meta) | 44 | 46 | client.memory = payload.instances | 45 | 47 | for (const key in payload.page) { | 46 | 48 | page[key] = payload.page[key] | |
Collapse file Copy file name to clipboardExpand all lines: shared/sanitizeString.js +5Lines changed: 5 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -6,3 +6,8 @@ export function sanitizeHtml(unsafe) { | 6 | 6 | export function sanitizeString(unsafe) { | 7 | 7 | return unsafe.replace(/<\//g, `<\\\/`) | 8 | 8 | } | | 9 | + | | 10 | +export function sanitizeInnerHtml(unsafe) { | | 11 | + if (unsafe === undefined || typeof(unsafe) !== 'string') return '' | | 12 | + return unsafe.replaceAll('<\\', '<') | | 13 | +} |
|