Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
How to deal with UnicodeDecodeError on non-Unicode request?
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  2 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
sergey  
View profile  
 More options Sep 28 2012, 6:48 am
From: sergey <sergey.naliva...@gmail.com>
Date: Fri, 28 Sep 2012 03:48:13 -0700 (PDT)
Local: Fri, Sep 28 2012 6:48 am
Subject: How to deal with UnicodeDecodeError on non-Unicode request?

I'm trying to attach 3rd party service to my site (payment system). This
service sends information to my Pyramid application at specific URL by POST
requests. This POST request is non-Unicode and data field includes
non-ASCII chars. And such request raises UnicodeDecodeError.

Reproduce such error is easy. Create non-Unicode file and put there
<form action="http://localhost:6543/" method="post">
       <input type="submit" name="button" value="NON-ASCII CHARS HERE">
</form>
then open page in browser and press button.

Even pylonsproject.org return Internal Server Error on such test.

I have already read at ICR #pyramid that malformed request should throw
exception. But as for me it is abnormal when simple HelloWorldApp that not
requires parameters at all have such behavior. Some hacker can use it to
fill out your exception log or mailbox (depending on where your tracebacks
goes).

So... Is there any way to process non-Unicode POST-request inside Pyramid
application?


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Chris McDonough  
View profile  
 More options Sep 28 2012, 10:21 am
From: Chris McDonough <chr...@plope.com>
Date: Fri, 28 Sep 2012 10:21:31 -0400
Local: Fri, Sep 28 2012 10:21 am
Subject: Re: How to deal with UnicodeDecodeError on non-Unicode request?

This is possibly more of a WebOb thing than a Pyramid thing.  WebOb
attempts to decode POST and GET variables when you ask for them, usually
from UTF-8.

If you want to continue to treat these requests as errors but suppress
exceptions, it's pretty easy, just register an exception view for
UnicodeDecodeError:

    @view_config(context=UnicodeDecodeError, renderer='string')
    def handle_decode_error(request):
        return 'Sorry, something is not encoded properly'

If, on the other hand, you don't want the request to be treated as an
error, but you want it to be accepted and processed by something, it's
probably possible, but how you do it would depend on the particulars of
the application.  Note that anything that accesses request.POST or
request.params will trigger an attempt at decoding; some Pyramid
predicates do this themselves, and of course if your application does
this, it will trigger the same.  So seeing a traceback in the context of
your particular application would probably be necessary.

- C


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »