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

chore: add manifest.json and service-worker to prepare pwa #24

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

phoebus-84
Copy link

No description provided.

`
<script>
if ('serviceWorker' in navigator) {
const swCode = \`${serviceWorkerCode.replace(/`/g, '\\`')}\`;

Check failure

Code scanning / CodeQL

Incomplete string escaping or encoding High

This does not escape backslash characters in the input.

Copilot Autofix AI about 1 month ago

To fix the problem, we need to ensure that all occurrences of backslashes and backticks in the serviceWorkerCode are properly escaped. This can be achieved by using a regular expression with the global flag to replace both backslashes and backticks. We will use a well-tested sanitization library if possible, but in this case, we will implement a custom solution using regular expressions.

We will modify the code to replace both backslashes and backticks in the serviceWorkerCode string. Specifically, we will update line 37 to use a regular expression that handles both characters.

Suggested changeset 1
vite.config.js

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/vite.config.js b/vite.config.js
--- a/vite.config.js
+++ b/vite.config.js
@@ -36,3 +36,3 @@
             if ('serviceWorker' in navigator) {
-              const swCode = \`${serviceWorkerCode.replace(/`/g, '\\`')}\`;
+              const swCode = \`${serviceWorkerCode.replace(/\\/g, '\\\\').replace(/`/g, '\\`')}\`;
               const blob = new Blob([swCode], { type: 'application/javascript' });
EOF
@@ -36,3 +36,3 @@
if ('serviceWorker' in navigator) {
const swCode = \`${serviceWorkerCode.replace(/`/g, '\\`')}\`;
const swCode = \`${serviceWorkerCode.replace(/\\/g, '\\\\').replace(/`/g, '\\`')}\`;
const blob = new Blob([swCode], { type: 'application/javascript' });
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant