GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Sanitization for click inputs · Issue #457 · pallets/click

Sanitization for click inputs #457

New issue
Copy link
New issue
Copy link
Closed
#1785
Closed
Sanitization for click inputs#457
#1785
Copy link
Assignees
Saif807380
Labels
promptInteractive input and confirmation
Milestone
8.0.0

Description

@Tylerlhess
Tylerlhess
opened on Nov 18, 2015
Issue body actions

I would like to see some method of easy sanitation after an input. I guess I could define a type and require that type for the input but that seems a little extravagant if I want to make sure that say a field entered is a valid email address during input or to strip out spaces automatically. I know I can do this in the code but it should be possible inside prompt.

Activity

  1. mitsuhiko commented on Nov 18, 2015

    @mitsuhiko
    mitsuhiko
    on Nov 18, 2015
    Contributor
    More actions

    Can you not use our callback system for this?

  2. mitsuhiko commented on Nov 18, 2015

    @mitsuhiko
    mitsuhiko
    on Nov 18, 2015
    Contributor
    More actions

    Oh I see. We might only invoke the type conversion but not the callbacks for prompts currently. I wonder if that can be changed though.

  3. piroux commented on Nov 19, 2015

    @piroux
    piroux
    on Nov 19, 2015
    More actions

    It would be a good feature indeed.

  4. Tylerlhess commented on Nov 23, 2015

    @Tylerlhess
    Tylerlhess
    on Nov 23, 2015
    Author
    More actions

    Yeah in the code I wrote I ended up just calling strip to sanitize it somewhat and prevent spaces at the beginning and the end but that does not actually validate the data. It does fix the issue I had of people using copy and paste and grabbing a space but not the underlying problem of allowing a complete input sanitization check.

  5. fdavis
    added
    enhancement
    on May 15, 2018
  6. davidism
    removed
    enhancement
    on Jul 3, 2020
  7. davidism
    added
    promptInteractive input and confirmation
    on Aug 9, 2020
  8. davidism commented on Feb 15, 2021

    @davidism
    davidism
    on Feb 15, 2021
    Member
    More actions

    Parameter.callback is already called for the result of prompt (or any other parameter source), but it's called after prompt returns, not inside it. So while it's possible to perform extra processing, if that processing raises a click.UsageError it exits instead of prompting again.

    I'm not sure if this was always the case or if it was due to recent refactors to the type processing pipeline. I think we can extend that refactoring a bit further though to address this issue. prompt is passed self.process_value, which only does type conversion. However, handle_parse_result calls full_process_value (which calls process_value) then applies the callback separately. There's no reason to have that separate anymore, and along with that there's no reason to have both process_value and full_process_value.

    1. Inline Parameter.process_value into Parameter.full_process_value.
    2. Rename full_process_value to process_value.
    3. Move the if self.callback: block from Parameter.handle_parse_result to the bottom of process_value.
  9. Saif807380 commented on Feb 23, 2021

    @Saif807380
    Saif807380
    on Feb 23, 2021
    Contributor
    More actions

    I'd like to work on this.

  10. davidism
    assigned
    Saif807380
    on Feb 23, 2021
  11. davidism
    added this to the 8.0.0 milestone on Feb 24, 2021
  12. davidism
    closed this as completedin #1785on Feb 24, 2021
  13. github-actions
    locked as resolved and limited conversation to collaborators on Mar 11, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

  • @Saif807380
    Saif807380

Labels

promptInteractive input and confirmation

Type

No type

Projects

No projects

    Milestone

    • 8.0.0

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

    You are visitor 01402775 — GeezerVison does not store the pages you look up.
    Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.