From 427a94fe9e12295b1ca5c2382784bf1333ca10b3 Mon Sep 17 00:00:00 2001 From: AtofStryker Date: Fri, 31 Jan 2025 14:18:03 -0500 Subject: [PATCH 1/2] fix: make sure privileged commands can run when there is a space in the spec or support file name --- cli/CHANGELOG.md | 1 + packages/driver/cypress/e2e/issues/issue 30933.cy.js | 7 +++++++ .../server/lib/privileged-commands/privileged-channel.js | 7 ++++++- 3 files changed, 14 insertions(+), 1 deletion(-) create mode 100644 packages/driver/cypress/e2e/issues/issue 30933.cy.js diff --git a/cli/CHANGELOG.md b/cli/CHANGELOG.md index d1076e5a7282..b85ceb58e4a1 100644 --- a/cli/CHANGELOG.md +++ b/cli/CHANGELOG.md @@ -6,6 +6,7 @@ _Released 2/11/2025 (PENDING)_ **Bugfixes:** - All commands performed in `after` and `afterEach` hooks will now correctly retry when a test fails. Commands that are actions like `.click()` and `.type()` will now perform the action in this situation also. Fixes [#2831](https://github.com/cypress-io/cypress/issues/2831). +- Privileged commands will now run correctly when a spec file or support file contains characters that require encoding. Fixes [#30933](https://github.com/cypress-io/cypress/issues/30933). **Dependency Updates:** diff --git a/packages/driver/cypress/e2e/issues/issue 30933.cy.js b/packages/driver/cypress/e2e/issues/issue 30933.cy.js new file mode 100644 index 000000000000..73b6284ec516 --- /dev/null +++ b/packages/driver/cypress/e2e/issues/issue 30933.cy.js @@ -0,0 +1,7 @@ +// @see https://github.com/cypress-io/cypress/issues/30933 +describe('issue #30933', { browser: '!webkit' }, () => { + it('is able to run privileged commands when there is a space in the spec name', () => { + cy.visit('/fixtures/files-form.html') + cy.get('#basic').selectFile('cypress/fixtures/valid.json') + }) +}) diff --git a/packages/server/lib/privileged-commands/privileged-channel.js b/packages/server/lib/privileged-commands/privileged-channel.js index da9771ceebb8..ab9fc75bebc4 100644 --- a/packages/server/lib/privileged-commands/privileged-channel.js +++ b/packages/server/lib/privileged-commands/privileged-channel.js @@ -92,7 +92,12 @@ script = replace.call(script, queryStringRegex, '') } - return stringIncludes.call(err.stack, script) + // stack URLs come in URI encoded by default. + // we need to make sure our script names are also URI encoded + // so the comparisons match + const scriptName = encodeURI(script) + + return stringIncludes.call(err.stack, scriptName) }) return filteredLines.length > 0 From 3c467b1dac44ecec8043deb8a54c992cdd6d1908 Mon Sep 17 00:00:00 2001 From: AtofStryker Date: Mon, 3 Feb 2025 09:34:08 -0500 Subject: [PATCH 2/2] update changelog --- cli/CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cli/CHANGELOG.md b/cli/CHANGELOG.md index b85ceb58e4a1..e02e636db7c8 100644 --- a/cli/CHANGELOG.md +++ b/cli/CHANGELOG.md @@ -6,7 +6,7 @@ _Released 2/11/2025 (PENDING)_ **Bugfixes:** - All commands performed in `after` and `afterEach` hooks will now correctly retry when a test fails. Commands that are actions like `.click()` and `.type()` will now perform the action in this situation also. Fixes [#2831](https://github.com/cypress-io/cypress/issues/2831). -- Privileged commands will now run correctly when a spec file or support file contains characters that require encoding. Fixes [#30933](https://github.com/cypress-io/cypress/issues/30933). +- Fixed an issue in Cypress [`14.0.0`](https://docs.cypress.io/guides/references/changelog#14-0-0) where privileged commands did not run correctly when a spec file or support file contained characters that required encoding. Fixes [#30933](https://github.com/cypress-io/cypress/issues/30933). **Dependency Updates:**