Skip to content
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

refactor: v2 release #6903

Open
wants to merge 849 commits into
base: main
Choose a base branch
from
Open

refactor: v2 release #6903

wants to merge 849 commits into from

Conversation

wmertens
Copy link
Member

@wmertens wmertens commented Sep 22, 2024

This PR is for showing progress on v2, and having installable npm packages.

DO NOT MERGE

The changes are meant to be readable and maintainable, so if things are unclear please let us know.

Copy link

changeset-bot bot commented Sep 22, 2024

🦋 Changeset detected

Latest commit: f640012

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 5 packages
Name Type
@qwik.dev/core Patch
eslint-plugin-qwik Patch
@qwik.dev/react Patch
@qwik.dev/router Patch
create-qwik Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

Copy link

pkg-pr-new bot commented Sep 23, 2024

Open in Stackblitz

npm i https://pkg.pr.new/QwikDev/qwik/@qwik.dev/core@6903
npm i https://pkg.pr.new/QwikDev/qwik/@qwik.dev/router@6903
npm i https://pkg.pr.new/QwikDev/qwik/eslint-plugin-qwik@6903
npm i https://pkg.pr.new/QwikDev/qwik/create-qwik@6903

commit: f640012

Copy link
Contributor

github-actions bot commented Sep 23, 2024

built with Refined Cloudflare Pages Action

⚡ Cloudflare Pages Deployment

Name Status Preview Last Commit
qwik-docs ✅ Ready (View Log) Visit Preview f640012

}
errorDiv.setAttribute('q:key', '_error_');
const journal: VNodeJournal = [];
vnode_getDOMChildNodes(journal, vHost).forEach((child) => errorDiv.appendChild(child));

Check warning

Code scanning / CodeQL

DOM text reinterpreted as HTML Medium

DOM text
is reinterpreted as HTML without escaping meta-characters.
DOM text
is reinterpreted as HTML without escaping meta-characters.
const insertBefore = journal[idx++] as Element | Text | null;
let newChild: any;
while (idx < length && typeof (newChild = journal[idx]) !== 'number') {
insertParent.insertBefore(newChild, insertBefore);

Check warning

Code scanning / CodeQL

DOM text reinterpreted as HTML Medium

DOM text
is reinterpreted as HTML without escaping meta-characters.
DOM text
is reinterpreted as HTML without escaping meta-characters.
@wmertens wmertens changed the title refactor: v2 framework rewrite refactor: v2 release Oct 8, 2024
@wmertens wmertens marked this pull request as ready for review October 17, 2024 21:25
@wmertens wmertens requested review from a team as code owners October 17, 2024 21:25
c.push(`\n/** Qwik Router Entries (${entries.length}) */`);
for (let i = 0; i < entries.length; i++) {
const entry = entries[i];
c.push(`export const ${entry.id} = () => import(${JSON.stringify(entry.filePath)});`);

Check warning

Code scanning / CodeQL

Improper code sanitization Medium

Code construction depends on an
improperly sanitized value
.

Copilot Autofix AI 4 months ago

To fix the problem, we need to ensure that entry.filePath is properly sanitized before being used in the dynamically generated JavaScript code. We can achieve this by escaping potentially dangerous characters in the entry.filePath string. This can be done by implementing a function similar to escapeUnsafeChars from the example provided in the background section.

  1. Implement a function escapeUnsafeChars to escape potentially dangerous characters.
  2. Use this function to sanitize entry.filePath before including it in the generated code.
Suggested changeset 1
packages/qwik-router/src/buildtime/runtime-generation/generate-entries.ts

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/packages/qwik-router/src/buildtime/runtime-generation/generate-entries.ts b/packages/qwik-router/src/buildtime/runtime-generation/generate-entries.ts
--- a/packages/qwik-router/src/buildtime/runtime-generation/generate-entries.ts
+++ b/packages/qwik-router/src/buildtime/runtime-generation/generate-entries.ts
@@ -2,2 +2,20 @@
 
+function escapeUnsafeChars(str: string): string {
+  const charMap: { [key: string]: string } = {
+    '<': '\\u003C',
+    '>': '\\u003E',
+    '/': '\\u002F',
+    '\\': '\\\\',
+    '\b': '\\b',
+   '\f': '\\f',
+   '\n': '\\n',
+   '\r': '\\r',
+   '\t': '\\t',
+   '\0': '\\0',
+   '\u2028': '\\u2028',
+   '\u2029': '\\u2029'
+ };
+ return str.replace(/[<>\b\f\n\r\t\0\u2028\u2029]/g, x => charMap[x]);
+}
+
 export function createEntries(ctx: BuildContext, c: string[]) {
@@ -25,3 +43,3 @@
     const entry = entries[i];
-    c.push(`export const ${entry.id} = () => import(${JSON.stringify(entry.filePath)});`);
+    c.push(`export const ${entry.id} = () => import(${escapeUnsafeChars(JSON.stringify(entry.filePath))});`);
   }
EOF
@@ -2,2 +2,20 @@

function escapeUnsafeChars(str: string): string {
const charMap: { [key: string]: string } = {
'<': '\\u003C',
'>': '\\u003E',
'/': '\\u002F',
'\\': '\\\\',
'\b': '\\b',
'\f': '\\f',
'\n': '\\n',
'\r': '\\r',
'\t': '\\t',
'\0': '\\0',
'\u2028': '\\u2028',
'\u2029': '\\u2029'
};
return str.replace(/[<>\b\f\n\r\t\0\u2028\u2029]/g, x => charMap[x]);
}

export function createEntries(ctx: BuildContext, c: string[]) {
@@ -25,3 +43,3 @@
const entry = entries[i];
c.push(`export const ${entry.id} = () => import(${JSON.stringify(entry.filePath)});`);
c.push(`export const ${entry.id} = () => import(${escapeUnsafeChars(JSON.stringify(entry.filePath))});`);
}
Copilot is powered by AI and may make mistakes. Always verify output.
Positive Feedback
Negative Feedback

Provide additional feedback

Please help us improve GitHub Copilot by sharing more details about this comment.

Please select one or more of the options
…-with-null

fix: replacing projection content with null or undefined
fix: prevent multiple store deserialization
wmertens and others added 20 commits February 25, 2025 20:34
this broke the dev-serve e2e tests
fix: using routeLoader$ result as component prop
fix: wrap WrappedSignal without unwrap flag
Version Packages (alpha)

Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
fix: don't wrap template literals with a function call inside in a si…
fix: finding vnodes on interaction
} else if (key === 'value' && key in element) {
(element as any).value = String(value);
} else if (key === dangerouslySetInnerHTML) {
(element as any).innerHTML = value!;

Check warning

Code scanning / CodeQL

DOM text reinterpreted as HTML Medium

DOM text
is reinterpreted as HTML without escaping meta-characters.
DOM text
is reinterpreted as HTML without escaping meta-characters.

Copilot Autofix AI 6 days ago

To fix the problem, we need to ensure that the value assigned to innerHTML is properly sanitized to prevent XSS attacks. This can be achieved by using a library like DOMPurify to sanitize the HTML content before assigning it to innerHTML.

  • Import the DOMPurify library.
  • Use DOMPurify.sanitize to sanitize the value before assigning it to innerHTML.
  • Ensure that the DOMPurify library is included in the project dependencies.
Suggested changeset 2
packages/qwik/src/core/client/vnode.ts

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/packages/qwik/src/core/client/vnode.ts b/packages/qwik/src/core/client/vnode.ts
--- a/packages/qwik/src/core/client/vnode.ts
+++ b/packages/qwik/src/core/client/vnode.ts
@@ -120,2 +120,3 @@
 import { isDev } from '@qwik.dev/core/build';
+import DOMPurify from 'dompurify';
 import { qwikDebugToString } from '../debug';
@@ -915,3 +916,3 @@
         } else if (key === dangerouslySetInnerHTML) {
-          (element as any).innerHTML = value!;
+          (element as any).innerHTML = DOMPurify.sanitize(value!);
           element.setAttribute(QContainerAttr, QContainerValue.HTML);
EOF
@@ -120,2 +120,3 @@
import { isDev } from '@qwik.dev/core/build';
import DOMPurify from 'dompurify';
import { qwikDebugToString } from '../debug';
@@ -915,3 +916,3 @@
} else if (key === dangerouslySetInnerHTML) {
(element as any).innerHTML = value!;
(element as any).innerHTML = DOMPurify.sanitize(value!);
element.setAttribute(QContainerAttr, QContainerValue.HTML);
packages/qwik/package.json
Outside changed files

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/packages/qwik/package.json b/packages/qwik/package.json
--- a/packages/qwik/package.json
+++ b/packages/qwik/package.json
@@ -10,3 +10,4 @@
   "dependencies": {
-    "csstype": "^3.1"
+    "csstype": "^3.1",
+    "dompurify": "^3.2.4"
   },
EOF
@@ -10,3 +10,4 @@
"dependencies": {
"csstype": "^3.1"
"csstype": "^3.1",
"dompurify": "^3.2.4"
},
This fix introduces these dependencies
Package Version Security advisories
dompurify (npm) 3.2.4 None
Copilot is powered by AI and may make mistakes. Always verify output.
Positive Feedback
Negative Feedback

Provide additional feedback

Please help us improve GitHub Copilot by sharing more details about this comment.

Please select one or more of the options
Varixo and others added 9 commits March 16, 2025 16:24
Co-authored-by: Varixo <admin@varixo.pl>
Co-authored-by: Miško Hevery <misko@hevery.com>
- custom serialization
- adds eslint rules
- renames signal classes to have ...Impl suffix so they don't clash with the abstract types
fix: change client side generated ID to start with build base
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants