UFront - Avoiding percent-encoding UTF-8 characters in GET requests

62 views
Skip to first unread message

Domagoj Štrekelj

unread,
Dec 9, 2014, 11:28:29 AM12/9/14
to haxe...@googlegroups.com
Hello again,

Recently, I've been toying around with forms in UFront. I made a simple app with a form that lets the user submit a string by POST request. The route handling the request returns a RedirectResult, passing the submitted string to another route. The receiving route then returns the string in a ViewResult. For example:


@:route("/$name", GET)
public function index(?name : String = "stranger")
{
return new ViewResult({
greeting: 'Hello, $name.',
});
}

@:route("/action/submit/", POST)
public function submit(args : {name : String})
{
return new RedirectResult(Config.app.basePath + args.name);
}


Submitting unreserved URI characters works as expected. UTF-8 characters (such as č, ć, ž, đ, š), on the other hand, get percent-encoded and printed as such by the GET request. However, when I directly return the submitted form arguments in the /action/submit/ route, I get the non-percent-encoded string, as expected.

I set my layout's character encoding, as well as the form's accepted charset, to UTF-8. The resulting web app prints UTF-8 characters just fine, but the ones received in during the GET request get percent-encoded.

Is it possible to "control" the percent-encoding of submitted characters? Or is there, perhaps, a method to decode the GET request data? I had no luck solving this so far, so I'm looking for a clue as to how to get this done.

Thank you in advance for any help you can provide,

Domagoj

Ian Harrigan

unread,
Dec 9, 2014, 3:33:51 PM12/9/14
to haxe...@googlegroups.com
This may help if you cant find a more elegant solution:

http://api.haxe.org/StringTools.html#urlDecode

Cheers,
Ian

Domagoj Štrekelj

unread,
Dec 10, 2014, 9:06:08 AM12/10/14
to haxe...@googlegroups.com
Hi Ian,

Thank you for your reply! I figured I'd have to use StringTools, but for some reason I completely overlooked the urlDecode method.

Still, I'm wondering whether there's something UFront can do about it directly. Either way, I'll make use of StringTools for now.

I'll mark this topic as complete if there aren't any other suggestions in the next couple of days.

Thanks again,

Domagoj

Jason O'Neil

unread,
Dec 12, 2014, 5:26:05 AM12/12/14
to haxe...@googlegroups.com

This is something I haven't considered, and it looks like something we should take care of at the HttpRequest level in ufront-mvc...

Could you create a new issue on Github: https://github.com/ufront/ufront-mvc/issues

I'd appreciate your thoughts on what behaviour you expect also. Issues in the format :

1) I run this code
2) it gives this result:
3) I'd prefer it to give this result:

are the easiest ones to fix :)

--
To post to this group haxe...@googlegroups.com
http://groups.google.com/group/haxelang?hl=en
---
You received this message because you are subscribed to the Google Groups "Haxe" group.
For more options, visit https://groups.google.com/d/optout.

Domagoj Štrekelj

unread,
Dec 13, 2014, 3:24:15 AM12/13/14
to haxe...@googlegroups.com
Hi Jason,

Thanks for replying!

I submitted a new issue, as requested. Hopefully it's detailed enough to figure out how to approach it. :)

Thank you for taking the time to look into this,

Domagoj
Reply all
Reply to author
Forward
0 new messages