Skip to content

Python REST API doesn't quote % character in queries #16

@patknight

Description

@patknight

pyral version 0.9.4

I'm using a query of the form rally.get('UserStory',fetch=True,query='Name = " -x% degradation in xxx"') and get back the 500 unexpected error page.

I turned on logging and found that, while the spaces in the query string are replaced to %20, the % character itself is untouched, leading to a malformed URL. If I wrap the query argument with a call to urllib.quote everything works.

I stepped through the call using pdb and find that at /usr/local/lib/python2.7/site-packages/pyral/query_builder.py(194)parenGroups() a call to
''.replace() has replaced a call to urllib.quote. Someone has made the deliberate decision at some point to only quote space characters.

Unfortunately, this was done before query_builder.py was uploaded to GitHub, so I can't use version history to determine why this was done. Obviously I can patch to escape % characters, but without understanding the rationale for pyral to only escape spaces in the query argument I can't contribute a better patch.

Can someone with more knowledge of what pyral is trying to do here let me know which characters pyral regards as safe and which should be escaped? I can then produce a general fix and not just a specific fix for my current use case.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions