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

feat: only folderId is needed, default values are managed by the pkg #2

Merged
merged 7 commits into from
Oct 3, 2024

Conversation

totallynotdavid
Copy link
Owner

No description provided.

@totallynotdavid totallynotdavid changed the title Authorizer feat: only folderId is needed, default values are managed by the pkg Oct 3, 2024
@totallynotdavid totallynotdavid merged commit 4122b90 into master Oct 3, 2024
1 check passed
@totallynotdavid totallynotdavid deleted the authorizer branch October 3, 2024 03:58
@@ -101,7 +145,9 @@
do {
let queryString = `(${parentQueries}) and mimeType != 'application/vnd.google-apps.folder' and trashed = false`;
if (query.trim() !== '') {
queryString += ` and name contains '${query}'`;
// Escape single quotes in query
const sanitizedQuery = query.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 2 months ago

To fix the problem, we need to ensure that both single quotes and backslashes are properly escaped in the query string. This can be achieved by using a regular expression that targets both characters and replaces them with their escaped counterparts. Specifically, we should replace single quotes with \' and backslashes with \\.

The best way to fix this without changing existing functionality is to update the query.replace call to handle both single quotes and backslashes. We will use a regular expression that matches both characters and replaces them accordingly.

Suggested changeset 1
src/services/google-drive.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/src/services/google-drive.ts b/src/services/google-drive.ts
--- a/src/services/google-drive.ts
+++ b/src/services/google-drive.ts
@@ -147,4 +147,4 @@
                     if (query.trim() !== '') {
-                        // Escape single quotes in query
-                        const sanitizedQuery = query.replace(/'/g, "\\'");
+                        // Escape single quotes and backslashes in query
+                        const sanitizedQuery = query.replace(/\\/g, "\\\\").replace(/'/g, "\\'");
                         queryString += ` and name contains '${sanitizedQuery}'`;
EOF
@@ -147,4 +147,4 @@
if (query.trim() !== '') {
// Escape single quotes in query
const sanitizedQuery = query.replace(/'/g, "\\'");
// Escape single quotes and backslashes in query
const sanitizedQuery = query.replace(/\\/g, "\\\\").replace(/'/g, "\\'");
queryString += ` and name contains '${sanitizedQuery}'`;
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