Tuesday 15 September 2015

python - Are underscores in URL query parameters valid? -



python - Are underscores in URL query parameters valid? -

i have noticed uri utilities python library produced rackspace in 2014 has parse_query_string method strip underscores:

>>> parse_query_string("_id=foo") {"id":"foo"}

is bad behaviour? here regex using:

_qs_pattern = re.compile(r'(?<![0-9])([a-za-z][a-za-z_0-9\-.]*)=([^&]+)')

i noticed removing first a-za-z set makes work expected:

_qs_pattern = re.compile(r'(?<![0-9])([a-za-z_0-9\-.]*)=([^&]+)')

any thought why did that?

the pattern not match _ is, have redefine little _

(?<![0-9])([_a-za-z][a-za-z_0-9\-.]*)=([^&]+)

python http url

No comments:

Post a Comment