jenkins-bot has submitted this change. ( 
https://gerrit.wikimedia.org/r/c/pywikibot/core/+/1336162?usp=email )

Change subject: editor: Preserve Windows commands without a file placeholder
......................................................................

editor: Preserve Windows commands without a file placeholder

str.find returns -1 when the placeholder is absent, which was treated as
true and caused valid registry commands to lose their final characters.

Check explicitly for the placeholder and only remove its argument when
present. Return commands without a placeholder without truncating them.

Change-Id: Ia9257ff384c690bc78501d8246c4e491f99a65ae
---
M pywikibot/editor.py
1 file changed, 3 insertions(+), 2 deletions(-)

Approvals:
  jenkins-bot: Verified
  Xqt: Looks good to me, approved




diff --git a/pywikibot/editor.py b/pywikibot/editor.py
index f58dada..7f2d13d 100644
--- a/pywikibot/editor.py
+++ b/pywikibot/editor.py
@@ -175,11 +175,12 @@
             _cmd = winreg.QueryValueEx(_key2, '')[0]
             # See T102465 for issues relating to using this value.
             cmd = _cmd
-            if cmd.find('%1'):
+            if '%1' in cmd:
                 cmd = cmd[:cmd.find('%1')]
                 # Remove any trailing character, which should be a quote or
                 # space and then remove all whitespace.
-                return cmd[:-1].strip()
+                cmd = cmd[:-1]
+            return cmd.strip()
         except OSError as e:
             # Catch any key lookup errors
             pywikibot.info(f'Unable to detect program for file extension '

--
To view, visit 
https://gerrit.wikimedia.org/r/c/pywikibot/core/+/1336162?usp=email
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.wikimedia.org/r/settings?usp=email

Gerrit-MessageType: merged
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Change-Id: Ia9257ff384c690bc78501d8246c4e491f99a65ae
Gerrit-Change-Number: 1336162
Gerrit-PatchSet: 2
Gerrit-Owner: Mahveotm <[email protected]>
Gerrit-Reviewer: Xqt <[email protected]>
Gerrit-Reviewer: jenkins-bot
_______________________________________________
Pywikibot-commits mailing list -- [email protected]
To unsubscribe send an email to [email protected]

Reply via email to