Skip to content

Conversation

atrnh
Copy link
Contributor

@atrnh atrnh commented Apr 7, 2023

Description

Replaced execSync with spawnSync in javascript/node/selenium-webdriver/common/seleniumManager.js.

I also had to change the way errors are handled a bit, because spawnSync doesn't raise exceptions. Instead, it returns an object with an error property. I was able to retain the existing error-handling constructs, but it feels a bit indirect due to how spawnSync works. Not sure if this is a big deal or not!

Motivation and Context

Since execSync does not escape shell metacharacters, attempting to execute a command with a space in it will fail. This is the case described in #11649, when the path to selenium-manager contains a space. This commit replaces execSync with spawnSync, which does escape shell metacharacters.

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist

  • I have read the contributing document.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have added tests to cover my changes.
  • All new and existing tests passed.

Since execSync does not escape shell metacharacters, attempting to
execute a command with a space in it will fail. This is the case when
the path to selenium-manager contains a space. This commit replaces
execSync with spawnSync, which does escape shell metacharacters.

Fixes SeleniumHQ#11649
@CLAassistant
Copy link

CLAassistant commented Apr 7, 2023

CLA assistant check
All committers have signed the CLA.

@harsha509 harsha509 added the C-nodejs JavaScript Bindings label Apr 11, 2023
@titusfortner titusfortner requested a review from harsha509 April 18, 2023 14:27
@titusfortner titusfortner added this to the 4.9 milestone Apr 18, 2023
Copy link
Member

@diemol diemol left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you, @atrnh!

I made some refinements because I got a few errors when I tried it locally. But it is indeed a good idea to use spawnSync instead of execSync, seems that command and arguments, plus return streams are easier to handle.

@diemol diemol merged commit a5b0ad9 into SeleniumHQ:trunk Apr 20, 2023
oriongonza pushed a commit to oriongonza/selenium that referenced this pull request Apr 24, 2023
…eniumHQ#11649) (SeleniumHQ#11873)

* replace execSync with spawnSync in seleniumManager.js

Since execSync does not escape shell metacharacters, attempting to
execute a command with a space in it will fail. This is the case when
the path to selenium-manager contains a space. This commit replaces
execSync with spawnSync, which does escape shell metacharacters.

Fixes SeleniumHQ#11649

* [javascript] Refine usage of spawnSync

---------

Co-authored-by: Sri Harsha <12621691+harsha509@users.noreply.github.com>
Co-authored-by: Diego Molina <diemol@users.noreply.github.com>
Co-authored-by: Diego Molina <diemol@gmail.com>
@atrnh atrnh deleted the atrnh-issue11649 branch April 25, 2023 16:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-nodejs JavaScript Bindings
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants