Skip to content

fix: Revert "feat: Enable CSP with nonce for Helix 5" #815

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 11, 2025
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
16 changes: 1 addition & 15 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@
"mdast-util-to-string": "4.0.0",
"micromark-util-subtokenize": "2.0.4",
"mime": "4.0.6",
"parse5-html-rewriting-stream": "7.0.0",
"rehype-format": "5.0.1",
"rehype-parse": "9.0.1",
"remark-parse": "11.0.0",
Expand Down
3 changes: 1 addition & 2 deletions src/html-pipe.js
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,6 @@ export async function htmlPipe(state, req) {

if (state.content.sourceBus === 'code' || state.info.originalExtension === '.md') {
state.timer?.update('serialize');
await setCustomResponseHeaders(state, req, res);
await renderCode(state, req, res);
} else {
state.timer?.update('parse');
Expand All @@ -166,14 +165,14 @@ export async function htmlPipe(state, req) {
await createPictures(state);
await extractMetaData(state, req);
await addHeadingIds(state);
await setCustomResponseHeaders(state, req, res);
await render(state, req, res);
state.timer?.update('serialize');
await tohtml(state, req, res);
await applyMetaLastModified(state, res);
}

setLastModified(state, res);
await setCustomResponseHeaders(state, req, res);
await setXSurrogateKeyHeader(state, req, res);
} catch (e) {
res.error = e.message;
Expand Down
214 changes: 0 additions & 214 deletions src/steps/csp.js

This file was deleted.

2 changes: 0 additions & 2 deletions src/steps/fetch-404.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
* governing permissions and limitations under the License.
*/
import { extractLastModified, recordLastModified } from '../utils/last-modified.js';
import { contentSecurityPolicyOnCode } from './csp.js';
import { computeContentPathKey, computeCodePathKey } from './set-x-surrogate-key-header.js';

/**
Expand All @@ -35,7 +34,6 @@ export default async function fetch404(state, req, res) {

// keep 404 response status
res.body = ret.body;
contentSecurityPolicyOnCode(state, res);
res.headers.set('last-modified', ret.headers.get('last-modified'));
res.headers.set('content-type', 'text/html; charset=utf-8');
}
Expand Down
5 changes: 0 additions & 5 deletions src/steps/render-code.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,6 @@
* governing permissions and limitations under the License.
*/
import mime from 'mime';
import {
contentSecurityPolicyOnCode,
} from './csp.js';

const CHARSET_RE = /charset=([^()<>@,;:"/[\]?.=\s]*)/i;

Expand All @@ -35,6 +32,4 @@ export default async function renderCode(state, req, res) {
}
}
res.headers.set('content-type', contentType);

contentSecurityPolicyOnCode(state, res);
}
2 changes: 0 additions & 2 deletions src/steps/render.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ import { h } from 'hastscript';
import { unified } from 'unified';
import rehypeParse from 'rehype-parse';
import { cleanupHeaderValue } from '@adobe/helix-shared-utils';
import { contentSecurityPolicyOnAST } from './csp.js';

function appendElement($parent, $el) {
if ($el) {
Expand Down Expand Up @@ -103,7 +102,6 @@ export default async function render(state, req, res) {
const $headHtml = await unified()
.use(rehypeParse, { fragment: true })
.parse(headHtml);
contentSecurityPolicyOnAST(res, $headHtml);
$head.children.push(...$headHtml.children);
}

Expand Down
Loading