Question about C:P:Unicode(::Encoding)

View: New views
7 Messages — Rating Filter:   Alert me  

Question about C:P:Unicode(::Encoding)

by Bernhard Graf-6 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

These plugins hook into prepare_parameters() to decode data.

Why does it leave query_- and body_parameters untouched?

--
Bernhard Graf

_______________________________________________
List: Catalyst@...
Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/catalyst@.../
Dev site: http://dev.catalyst.perl.org/

Re: Question about C:P:Unicode(::Encoding)

by Bill Moseley :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message



On Sat, Oct 24, 2009 at 1:26 PM, Bernhard Graf <catalyst4@...> wrote:
These plugins hook into prepare_parameters() to decode data.

Why does it leave query_- and body_parameters untouched?

Always seemed like a bug to me.


http://www.mail-archive.com/catalyst@.../msg02350.html
http://www.mail-archive.com/catalyst@.../msg05312.html
http://www.mail-archive.com/catalyst@.../msg04321.html

I wonder about something like this, although might be cases where there's something in there that should not be decoded.

after 'prepare_body_parameters' => sub {
    my $c = shift;

    my $v = Data::Visitor::Callback->new(
        ignore_return_values => 1,
        value                => sub {
            $_ = decode_utf8( $_, $CHECK ) unless Encode::is_utf8( $_ );
        },
    );

    $v->visit( $c->req->body_parameters );

    return;
};

Although I have cryptic notes elsewhere where I had problems with Data::Visitor.  Hum, should have taken better notes.






--
Bill Moseley
moseley@...

_______________________________________________
List: Catalyst@...
Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/catalyst@.../
Dev site: http://dev.catalyst.perl.org/

Re: Question about C:P:Unicode(::Encoding)

by Tomas Doran :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


> On Sat, Oct 24, 2009 at 1:26 PM, Bernhard Graf <catalyst4@...
> > wrote:
> These plugins hook into prepare_parameters() to decode data.
>
> Why does it leave query_- and body_parameters untouched?
>
> Always seemed like a bug to me.

I agree.

I've also taken some of your other thoughts onboard.

I've just sent 0.5 to CPAN which corrects this issue.

Cheers
t0m


_______________________________________________
List: Catalyst@...
Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/catalyst@.../
Dev site: http://dev.catalyst.perl.org/

Re: Question about C:P:Unicode(::Encoding)

by Bill Moseley :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message



On Wed, Nov 4, 2009 at 6:11 PM, Tomas Doran <bobtfish@...> wrote:

On Sat, Oct 24, 2009 at 1:26 PM, Bernhard Graf <catalyst4@...> wrote:
These plugins hook into prepare_parameters() to decode data.

Why does it leave query_- and body_parameters untouched?

Always seemed like a bug to me.

I agree.

I've also taken some of your other thoughts onboard.

I've just sent 0.5 to CPAN which corrects this issue.

Great!  And nice work on the upload file names.

I've been using Data::Visitor::Callback to decode the parameters.   Not sure if it's any better,  but then the keys are decoded as well as values.

I've said this before, but I think this is something that Catalyst core should handle, not left to a plugin.

 

--
Bill Moseley
moseley@...

_______________________________________________
List: Catalyst@...
Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/catalyst@.../
Dev site: http://dev.catalyst.perl.org/

Re: Question about C:P:Unicode(::Encoding)

by Tomas Doran :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


On 5 Nov 2009, at 05:04, Bill Moseley wrote:
> Great!  And nice work on the upload file names.

For that, you can thank Masahiro Chiba, that part was his patch :)

> I've been using Data::Visitor::Callback to decode the parameters.    
> Not sure if it's any better,  but then the keys are decoded as well  
> as values.

Hmm, I hadn't thought of the case where you'd want keys as uft8, but  
that's perfectly valid.

I'd certainly take a patch to do that, but I'm afraid my enthusiasm  
has vanished at the moment :)

> I've said this before, but I think this is something that Catalyst  
> core should handle, not left to a plugin.

I'd probably agree with you, at least as a configurable parameter -  
some of the things I'm doing now are really horribly breaking  
abstraction to get things done..

Branch on 5.80 welcome, although we wouldn't want to change behavior  
by default (at least any time soon, or only for new apps)..

Cheers
t0m


_______________________________________________
List: Catalyst@...
Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/catalyst@.../
Dev site: http://dev.catalyst.perl.org/

Re: Question about C:P:Unicode(::Encoding)

by Bill Moseley :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message



On Thu, Nov 5, 2009 at 1:24 PM, Tomas Doran <bobtfish@...> wrote:


I've said this before, but I think this is something that Catalyst core should handle, not left to a plugin.

I'd probably agree with you, at least as a configurable parameter - some of the things I'm doing now are really horribly breaking abstraction to get things done..

In general, I think the right place to do the decoding is as close to the "edge" of the program as possible.  That might mean HTTP::Body -- or in the Engine code for query params.  But, I haven't looked at it.  Where do you think that "edge" would be?


--
Bill Moseley
moseley@...

_______________________________________________
List: Catalyst@...
Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/catalyst@.../
Dev site: http://dev.catalyst.perl.org/

Re: Question about C:P:Unicode(::Encoding)

by Tomas Doran :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


On 5 Nov 2009, at 21:31, Bill Moseley wrote:
> In general, I think the right place to do the decoding is as close  
> to the "edge" of the program as possible.  That might mean  
> HTTP::Body -- or in the Engine code for query params.  But, I  
> haven't looked at it.  Where do you think that "edge" would be?

Yes.

Having not thought about it too hard, I'd say the engine code +  
Catalyst::Request::Upload + probably HTTP::Body are the right places :)

Cheers
t0m

_______________________________________________
List: Catalyst@...
Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/catalyst@.../
Dev site: http://dev.catalyst.perl.org/