Re: [Erlangweb-users] UTF8 string parse patch
Brought to you by:
etcerlangweb,
paulgray
|
From: Michal P. <mic...@er...> - 2010-01-19 10:34:28
|
Hi Jacky! We are very pleased with your opinion about Erlang Web. Thank you for your warm support! Patch you sent have been reviewed and applied to the framework's sources - the changeset is b44a6e460554 (http://bitbucket.org/etc/erlang-web/changeset/b44a6e460554/). I've added also utf8_api:ustring call in wtype_password (to behave in the same way as wtype_string and wtype_text). Thank you very much! ----- "jacky zhao" <jac...@gm...> wrote: > Hello, > > I have been using Erlang-Web for a while, that's a real time-saver. > > I possiblly found a *problem* in wtype_string and related basic > wtypes. Here > is the detail. > > When validating a input string(for example, the UTF-8 encoding string, > like > Chinese/Japanese/Korean characters), the wtype_string:validate > function is > using utf8_api:ulength try to decode utf8 from bytes to string, and > then get > the correct length. It's a carefully design, but no enought. The > returned > string needs to be decoded as well. > > The attached file is a rough patch. > > Basically, I just changed the utf8_api.erl to export a new function > ustring() and use it in wtype_string, wtype_text and wtype_password. > It's > just try the utf8 decoder anyway, if falure(eg, not a utf8 encoding > string), > just return the input string. In most case, this is a acceptable > solution(utf8 is widly used), but may not fit for all scenarios. > > To solve the problem totally, possiblly we needs to modify the > e_mod_inet.erl add some code to detect the charset value in request's > http > content-type header(such as {"content-type", "form-post-url-encode; > charset=ANY_ENCODING"}), and using the right decoder(such as: big-5, > shift-js, gbk and so on) to parse the input. But it's hard to find > those > decoders in Erlang, and the utf8 is the most adaptable and standard > choice. > > Regards. > > Jackyz. > _______________________________________________ > Erlangweb-users mailing list > Erl...@li... > https://lists.sourceforge.net/lists/listinfo/erlangweb-users > http://www.erlang-web.org/ Best regards, Michal Ptaszek --------------------------------------------------- --------------------------------------------------- WE'VE CHANGED NAMES! Since January 1st 2010 Erlang Training and Consulting Ltd. has become ERLANG SOLUTIONS LTD. www.erlang-solutions.com |