Hello,

I found a few bugs concerning utf8 handling in dtl templates and in forms.
Value stored in database are stored with large integer value of characters and 
those
would end up into the template result and make xmerl complain and bug.

I modified erlydtl_compiler:format to correct this:
diff -r old/lib/erlydtl-0.5.3/src/erlydtl/erlydtl_compiler.erl 
new/lib/erlydtl-0.5.3/src/erlydtl/erlydtl_compiler.erl
548c548,552
<     auto_escape(format_number_ast(Ast), Context).
---
>     Tmp = format_number_ast(Ast),
>     %% Value is a list of Unicode codepoints.  We need to convert that
>     %% to UTF-8.
>     Tmp2 = erl_syntax:application(erl_syntax:atom(erlydtl_filters), 
> erl_syntax:atom(utf32_to_utf8), [Tmp]),
>     auto_escape(Tmp2, Context).

the "utf32_to_utf8" function I put in erlydtl_filters ; but I'm sure there
must be a more appropriate place for it. It was a quick hack.
diff -r old/lib/erlydtl-0.5.3/src/erlydtl/erlydtl_filters.erl 
new/lib/erlydtl-0.5.3/src/erlydtl/erlydtl_filters.erl
192a193,199
> utf32_to_utf8(Input) when is_list(Input) ->
>     % Convert utf32 strings into utf8
>     {ok, UTF8} = utf8:to_binary(Input),
>     binary_to_list(UTF8);
> utf32_to_utf8(Input) ->
>     Input.
>

I also found another problem with forms. wpart forms would retrieve the large 
integer
character and bug.
Here's what I did to fix it:
diff -r old/lib/wparts-1.4/src/wpart_derived.erl 
new/lib/wparts-1.4/src/wpart_derived.erl
135c135
<     Input = Module:build_html_tag(LName, Params, find(LName, Defaults)),
---
>     Input = Module:build_html_tag(LName, Params, 
> erlydtl_filters:utf32_to_utf8(find(LName, Defaults))),


I hope it'll helps.

Regards.

------------------------------------------------------------------------------
Download Intel&#174; Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
_______________________________________________
Erlangweb-users mailing list
Erlangweb-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/erlangweb-users
http://www.erlang-web.org/

Reply via email to