mod_mam_mnesia: Ignore whitespace within <value/>
Ignore the whitespace when a form field value is specified like this, for example: <value> juliet@example.com </value>
This commit is contained in:
parent
f2652f613f
commit
d7fd0f5d68
|
@ -737,13 +737,13 @@ parse_form(Fields) when is_list(Fields) ->
|
||||||
Parse =
|
Parse =
|
||||||
fun(#xmlel{name = <<"field">>,
|
fun(#xmlel{name = <<"field">>,
|
||||||
attrs = Attrs,
|
attrs = Attrs,
|
||||||
children = [#xmlel{name = <<"value">>, children = [Value]}]},
|
children = [#xmlel{name = <<"value">>, children = Els}]},
|
||||||
Form) ->
|
Form) ->
|
||||||
case xml:get_attr_s(<<"var">>, Attrs) of
|
case xml:get_attr_s(<<"var">>, Attrs) of
|
||||||
<<"FORM_TYPE">> ->
|
<<"FORM_TYPE">> ->
|
||||||
Form;
|
Form;
|
||||||
<<"start">> ->
|
<<"start">> ->
|
||||||
CData = xml:get_cdata([Value]),
|
CData = get_cdata_without_whitespace(Els),
|
||||||
case jlib:datetime_string_to_timestamp(CData) of
|
case jlib:datetime_string_to_timestamp(CData) of
|
||||||
undefined ->
|
undefined ->
|
||||||
Form#mam_filter{start = error};
|
Form#mam_filter{start = error};
|
||||||
|
@ -751,7 +751,7 @@ parse_form(Fields) when is_list(Fields) ->
|
||||||
Form#mam_filter{start = Start}
|
Form#mam_filter{start = Start}
|
||||||
end;
|
end;
|
||||||
<<"end">> ->
|
<<"end">> ->
|
||||||
CData = xml:get_cdata([Value]),
|
CData = get_cdata_without_whitespace(Els),
|
||||||
case jlib:datetime_string_to_timestamp(CData) of
|
case jlib:datetime_string_to_timestamp(CData) of
|
||||||
undefined ->
|
undefined ->
|
||||||
Form#mam_filter{fin = error};
|
Form#mam_filter{fin = error};
|
||||||
|
@ -759,7 +759,7 @@ parse_form(Fields) when is_list(Fields) ->
|
||||||
Form#mam_filter{fin = End}
|
Form#mam_filter{fin = End}
|
||||||
end;
|
end;
|
||||||
<<"with">> ->
|
<<"with">> ->
|
||||||
CData = xml:get_cdata([Value]),
|
CData = get_cdata_without_whitespace(Els),
|
||||||
case jlib:string_to_jid(CData) of
|
case jlib:string_to_jid(CData) of
|
||||||
error ->
|
error ->
|
||||||
Form#mam_filter{with = error};
|
Form#mam_filter{with = error};
|
||||||
|
@ -856,6 +856,12 @@ check_request(#mam_query{index = Index, filter = Filter})
|
||||||
check_request(_Query) ->
|
check_request(_Query) ->
|
||||||
ok.
|
ok.
|
||||||
|
|
||||||
|
-spec get_cdata_without_whitespace([xmlel() | cdata()]) -> binary().
|
||||||
|
|
||||||
|
get_cdata_without_whitespace(Els) ->
|
||||||
|
CData = xml:get_cdata(Els),
|
||||||
|
re:replace(CData, <<"[[:space:]]">>, <<"">>, [global, {return, binary}]).
|
||||||
|
|
||||||
%%--------------------------------------------------------------------
|
%%--------------------------------------------------------------------
|
||||||
%% Send responses.
|
%% Send responses.
|
||||||
%%--------------------------------------------------------------------
|
%%--------------------------------------------------------------------
|
||||||
|
|
Loading…
Reference in New Issue