2

I have a an url encoded with URL encoding, namely : /filebrowser/?cd=bank/fran%E7ais/essais

The problem is that if I retrieve the argument through :

path = request.GET.get('relative_h', None)

I get :

/filebrowser/?cd=bank/fran�ais/essais

instead of:

/filebrowser/?cd=bank/français/essais

or :

/filebrowser/?cd=bank/fran%E7ais/essais

Yet, %E7 does correspond to 'ç', as you can see there.

And since the %E7 is decoded with the replacement character, I can't even use urllib.parse.unquote to get my 'ç' back...

Is there a way to get the raw argument or the correctly decoded string?

1 Answers1

0

Switching the request encoding to latin-1 before accessing the parameter returned the correctly decoded string for me, when running your example locally.

request.encoding = 'latin-1'
path = request.GET.get('relative_h', None)

However, I'm not able to tell you why that would be, since I would have assumed that the default encoding of utf-8 would have handled that particular character.

Will Keeling
  • 22,055
  • 4
  • 51
  • 61