Skip to content

Commit 18aec30

Browse files
authored
install_addon() didn't take into account dir paths with trailing slashes (#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
1 parent 0e4e739 commit 18aec30

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

py/selenium/webdriver/firefox/webdriver.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,10 @@ def install_addon(self, path, temporary=False) -> str:
125125

126126
if os.path.isdir(path):
127127
fp = BytesIO()
128-
path_root = len(path) + 1 # account for trailing slash
128+
# filter all trailing slash found in path
129+
path = os.path.normpath(path)
130+
# account for trailing slash that will be added by os.walk()
131+
path_root = len(path) + 1
129132
with zipfile.ZipFile(fp, "w", zipfile.ZIP_DEFLATED) as zipped:
130133
for base, _, files in os.walk(path):
131134
for fyle in files:

0 commit comments

Comments
 (0)