Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

shlex: bug in posix mode handling of empty strings #66198

Closed
isoschiz mannequin opened this issue Jul 17, 2014 · 6 comments
Closed

shlex: bug in posix mode handling of empty strings #66198

isoschiz mannequin opened this issue Jul 17, 2014 · 6 comments
Labels
type-bug An unexpected behavior, bug, or error

Comments

@isoschiz
Copy link
Mannequin

isoschiz mannequin commented Jul 17, 2014

BPO 21999
Nosy @vsajip, @ezio-melotti, @bitdancer, @phmc
Files
  • shlex.default.patch
  • shlex.2.7.patch
  • Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

    Show more details

    GitHub fields:

    assignee = None
    closed_at = <Date 2016-08-09.14:07:22.926>
    created_at = <Date 2014-07-17.16:37:00.766>
    labels = ['type-bug']
    title = 'shlex: bug in posix mode handling of empty strings'
    updated_at = <Date 2016-08-09.14:07:22.924>
    user = 'https://bugs.python.org/isoschiz'

    bugs.python.org fields:

    activity = <Date 2016-08-09.14:07:22.924>
    actor = 'python-dev'
    assignee = 'none'
    closed = True
    closed_date = <Date 2016-08-09.14:07:22.926>
    closer = 'python-dev'
    components = []
    creation = <Date 2014-07-17.16:37:00.766>
    creator = 'isoschiz'
    dependencies = []
    files = ['35983', '35984']
    hgrepos = []
    issue_num = 21999
    keywords = ['patch']
    message_count = 6.0
    messages = ['223348', '223512', '228136', '272083', '272251', '272253']
    nosy_count = 6.0
    nosy_names = ['vinay.sajip', 'ezio.melotti', 'r.david.murray', 'python-dev', 'pconnell', 'isoschiz']
    pr_nums = []
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = 'behavior'
    url = 'https://bugs.python.org/issue21999'
    versions = ['Python 2.7', 'Python 3.5']

    @isoschiz
    Copy link
    Mannequin Author

    isoschiz mannequin commented Jul 17, 2014

    Minimal testcase of the problem situation is tokenising (with posix mode on):

    ''),

    Specifically, an empty string, followed by a non-word character, followed by a non-space character. In this case, the token buffer is empty and due to a missing check for (self.posix and quoted), an extra token is consumed and returned in the wrong order:

    >>> s = shlex.shlex("'')abc", posix=True)
    >>> s.get_token()
    'abc'
    >>> s.get_token()
    ')'
    >>> s.get_token()
    >>> 

    I have patches to fix this issue in both default and 2.7. I've also checked there are no other occurrences of the same typo.

    @bitdancer
    Copy link
    Member

    Vinay has a patch improving shlex parsing in bpo-1521950, but it doesn't seem to address this case, so I'm adding him as nosy.

    @bitdancer bitdancer changed the title shlex: bug in posix more handling of empty strings shlex: bug in posix mode handling of empty strings Jul 20, 2014
    @bitdancer bitdancer added the type-bug An unexpected behavior, bug, or error label Jul 20, 2014
    @vsajip
    Copy link
    Member

    vsajip commented Oct 1, 2014

    I've updated the patch on bpo-1521950 to address this case, and also added a test there (which is not in this patch). Thanks, RDM, for the notification.

    @vsajip
    Copy link
    Member

    vsajip commented Aug 6, 2016

    After the patch for bpo-1521950 was applied, this problem no longer occurs on default/3.6.

    Removing 3.4 as it's in "security patches only" mode.

    @python-dev
    Copy link
    Mannequin

    python-dev mannequin commented Aug 9, 2016

    New changeset cf04243e8d7d by Vinay Sajip in branch '2.7':
    Issue bpo-21999: Handled empty strings correctly when in POSIX mode.
    https://hg.python.org/cpython/rev/cf04243e8d7d

    @python-dev
    Copy link
    Mannequin

    python-dev mannequin commented Aug 9, 2016

    New changeset 4f02ad46a0a8 by Vinay Sajip in branch '3.5':
    Closes bpo-21999: Handled empty strings correctly when in POSIX mode.
    https://hg.python.org/cpython/rev/4f02ad46a0a8

    New changeset a8e74448678c by Vinay Sajip in branch 'default':
    Closes bpo-21999: (Empty) merge from 3.5.
    https://hg.python.org/cpython/rev/a8e74448678c

    @python-dev python-dev mannequin closed this as completed Aug 9, 2016
    @ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    type-bug An unexpected behavior, bug, or error
    Projects
    None yet
    Development

    No branches or pull requests

    2 participants