Re: [PATCH v2 1/4] git-p4: yes/no prompts should sanitize user text
- From
Denton Liu <liu.denton@gmail.com>
- Date
- Dec 11, 2019, 11:59 UTC
- Message-ID
- <20191211115900.GC41678@generichostname>
- In-Reply-To
- <527b7b8f8a25a9f8abc326004792507f7fe5e373.1575991374.git.gitgitgadget@gmail.com>
On Tue, Dec 10, 2019 at 03:22:51PM +0000, Ben Keene via GitGitGadget wrote:
Show 9 quoted lines
> @@ -1779,7 +1790,7 @@ def edit_template(self, template_file):
> return True
>
> while True:
> - response = raw_input("Submit template unchanged. Submit anyway? [y]es, [n]o (skip this patch) ")
> + response = prompt("Submit template unchanged. Submit anyway? [y]es, [n]o (skip this patch) ", ["y", "n"])
> if response == 'y':
> return True
> if response == 'n':One more thing, since we guarantee that prompt() returns 'y' or 'n' and it handles the looping logic, we can get rid of the surrounding while.
Show 11 quoted lines
> @@ -2350,8 +2361,8 @@ def run(self, args):
> # prompt for what to do, or use the option/variable
> if self.conflict_behavior == "ask":
> print("What do you want to do?")
> - response = raw_input("[s]kip this commit but apply"
> - " the rest, or [q]uit? ")
> + response = prompt("[s]kip this commit but apply"
> + " the rest, or [q]uit? ", ["s", "q"])
> if not response:
> continue
> elif self.conflict_behavior == "skip":Same with this, we can remove the surrounding `while`.
> -- > gitgitgadget >