From 3e683a7621f9fd3de4cee806416b2be1c3ffb719 Mon Sep 17 00:00:00 2001 From: Holger Weiss Date: Sat, 15 Aug 2015 17:58:00 +0200 Subject: [PATCH] mod_mam_mnesia: Strip CDATA from form fields Don't let mod_mam_mnesia stumble over additional whitespace when parsing form fields. --- mod_mam_mnesia/src/mod_mam_mnesia.erl | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/mod_mam_mnesia/src/mod_mam_mnesia.erl b/mod_mam_mnesia/src/mod_mam_mnesia.erl index 0663a98..a3068f7 100644 --- a/mod_mam_mnesia/src/mod_mam_mnesia.erl +++ b/mod_mam_mnesia/src/mod_mam_mnesia.erl @@ -730,6 +730,10 @@ parse_form(#xmlel{} = Query) -> #mam_filter{} end; parse_form(Fields) when is_list(Fields) -> + StripCData = + fun(#xmlel{children = Els} = Field) -> + Field#xmlel{children = xml:remove_cdata(Els)} + end, Parse = fun(#xmlel{name = <<"field">>, attrs = Attrs, @@ -770,7 +774,7 @@ parse_form(Fields) when is_list(Fields) -> ?DEBUG("Got unexpected form element: ~p", [El]), Form end, - lists:foldl(Parse, #mam_filter{}, Fields). + lists:foldl(Parse, #mam_filter{}, lists:map(StripCData, Fields)). -spec get_page_size_conf(binary()) -> mam_page_size_conf().