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

parse_qsl problems #117

Open
mihaiush opened this issue Jun 8, 2022 · 1 comment
Open

parse_qsl problems #117

mihaiush opened this issue Jun 8, 2022 · 1 comment

Comments

@mihaiush
Copy link

mihaiush commented Jun 8, 2022

Hi,
It seems there is something wrong with parse_qsl function from .src/_apachemodule.c
For this code:

from mod_python import apache
from mod_python import util

def index(req):
    apache.log_error('args: {}'.format(req.args))
    apache.log_error('parse_qsl: {}'.format(util.parse_qsl(req.args)))
    req.content_type = "text/plain"
    return "pong\n"

I get:

[Wed Jun 08 11:09:01.207959 2022] [:error] [pid 18:tid 140612959446784] args: x=10&y=20
[Wed Jun 08 11:09:01.207974 2022] [:error] [pid 18:tid 140612959446784] parse_qsl: [('10', '10'), ('20', '20')]

instead of:

parse_qsl: [('x', '10'), ('y', '20')]
@wom-bat
Copy link
Contributor

wom-bat commented Sep 6, 2022

Try converting to bytes and back.
I find I need:

  query = util.parse_qs(req.args.encode(encoding='utf-8'))
  newquery = {}
   for q in query:
       val = query[q][0].decode('utf-8')1
       newquery[q.decode('utf-8')] = [val]
   query = newquery
   

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants