Skip to content

Commit

Permalink
install_addon() didn't take into account dir paths with trailing slas…
Browse files Browse the repository at this point in the history
…hes (#13694)

* install_addon() didn't take into account dir paths with trailing slashes

If install_addon() was called with a path argument pointing to
to an extension directory and the path argument value itself ended
with a trailing slash, install_addon() would eat the first
character of each file it would be adding to the synthetized xpi file.

Fixes #13685

* replacing os.rpath with os.path.normpath()

suggested by codiumai-pr-agent-pro
  • Loading branch information
jkbzh authored Mar 26, 2024
1 parent 0e4e739 commit 18aec30
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion py/selenium/webdriver/firefox/webdriver.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,10 @@ def install_addon(self, path, temporary=False) -> str:

if os.path.isdir(path):
fp = BytesIO()
path_root = len(path) + 1 # account for trailing slash
# filter all trailing slash found in path
path = os.path.normpath(path)
# account for trailing slash that will be added by os.walk()
path_root = len(path) + 1
with zipfile.ZipFile(fp, "w", zipfile.ZIP_DEFLATED) as zipped:
for base, _, files in os.walk(path):
for fyle in files:
Expand Down

0 comments on commit 18aec30

Please sign in to comment.