25
1
mirror of https://github.com/processone/ejabberd.git synced 2024-11-30 16:36:29 +01:00

* src/Makefile.in: Added install rule

* src/jlib.erl: Added checks for JID parts length

SVN Revision: 157
This commit is contained in:
Alexey Shchepin 2003-10-21 20:28:36 +00:00
parent f01ea1f0d5
commit ed124e15e9
3 changed files with 62 additions and 24 deletions

View File

@ -1,3 +1,9 @@
2003-10-21 Alexey Shchepin <alexey@sevcom.net>
* src/Makefile.in: Added install rule
* src/jlib.erl: Added checks for JID parts length
2003-10-20 Alexey Shchepin <alexey@sevcom.net> 2003-10-20 Alexey Shchepin <alexey@sevcom.net>
* src/mod_vcard.erl: Added checks for stringprep results * src/mod_vcard.erl: Added checks for stringprep results

View File

@ -6,6 +6,8 @@ CPPFLAGS = @CPPFLAGS@
LDFLAGS = @LDFLAGS@ LDFLAGS = @LDFLAGS@
LIBS = @LIBS@ LIBS = @LIBS@
prefix = @prefix@
INCLUDES = @ERLANG_CFLAGS@ @EXPAT_CFLAGS@ INCLUDES = @ERLANG_CFLAGS@ @EXPAT_CFLAGS@
LIBDIRS = @ERLANG_LIBS@ @EXPAT_LIBS@ LIBDIRS = @ERLANG_LIBS@ @EXPAT_LIBS@
@ -14,6 +16,13 @@ SUBDIRS = @mod_irc@ @mod_pubsub@ @mod_muc@ stringprep
ERLSHLIBS = expat_erl.so ERLSHLIBS = expat_erl.so
DESTDIR =
EJABBERDDIR = $(DESTDIR)/var/lib/ejabberd
BEAMDIR = $(EJABBERDDIR)/beam
PRIVDIR = $(EJABBERDDIR)/priv
SODIR = $(PRIVDIR)/lib
all: all-recursive $(ERLSHLIBS) compile-beam all: all-recursive $(ERLSHLIBS) compile-beam
compile-beam: compile-beam:
@ -38,6 +47,12 @@ $(ERLSHLIBS): %.so: %.c
-lei \ -lei \
-o $@ -fpic -shared \ -o $@ -fpic -shared \
install: all
mkdir -p $(BEAMDIR)
cp *.beam $(BEAMDIR)
mkdir -p $(SODIR)
cp *.so $(SODIR)
clean: clean-recursive clean: clean-recursive
rm -f *.beam $(ERLSHLIBS) rm -f *.beam $(ERLSHLIBS)

View File

@ -138,13 +138,13 @@ remove_attr(Attr, {xmlelement, Name, Attrs, Els}) ->
make_jid(User, Server, Resource) -> make_jid(User, Server, Resource) ->
case stringprep:nodeprep(User) of case nodeprep(User) of
error -> error; error -> error;
LUser -> LUser ->
case stringprep:nameprep(Server) of case nameprep(Server) of
error -> error; error -> error;
LServer -> LServer ->
case stringprep:resourceprep(Resource) of case resourceprep(Resource) of
error -> error; error -> error;
LResource -> LResource ->
#jid{user = User, #jid{user = User,
@ -163,11 +163,11 @@ make_jid({User, Server, Resource}) ->
string_to_jid(J) -> string_to_jid(J) ->
string_to_jid1(J, ""). string_to_jid1(J, "").
string_to_jid1([$@ | J], "") -> string_to_jid1([$@ | _J], "") ->
error; error;
string_to_jid1([$@ | J], N) -> string_to_jid1([$@ | J], N) ->
string_to_jid2(J, lists:reverse(N), ""); string_to_jid2(J, lists:reverse(N), "");
string_to_jid1([$/ | J], "") -> string_to_jid1([$/ | _J], "") ->
error; error;
string_to_jid1([$/ | J], N) -> string_to_jid1([$/ | J], N) ->
string_to_jid3(J, "", lists:reverse(N), ""); string_to_jid3(J, "", lists:reverse(N), "");
@ -178,13 +178,13 @@ string_to_jid1([], "") ->
string_to_jid1([], N) -> string_to_jid1([], N) ->
make_jid("", lists:reverse(N), ""). make_jid("", lists:reverse(N), "").
string_to_jid2([$/ | J], N, "") -> string_to_jid2([$/ | _J], _N, "") ->
error; error;
string_to_jid2([$/ | J], N, S) -> string_to_jid2([$/ | J], N, S) ->
string_to_jid3(J, N, lists:reverse(S), ""); string_to_jid3(J, N, lists:reverse(S), "");
string_to_jid2([C | J], N, S) -> string_to_jid2([C | J], N, S) ->
string_to_jid2(J, N, [C | S]); string_to_jid2(J, N, [C | S]);
string_to_jid2([], N, "") -> string_to_jid2([], _N, "") ->
error; error;
string_to_jid2([], N, S) -> string_to_jid2([], N, S) ->
make_jid(N, lists:reverse(S), ""). make_jid(N, lists:reverse(S), "").
@ -220,7 +220,6 @@ is_nodename(J) ->
% TODO: UNICODE support
%tolower_c(C) when C >= $A, C =< $Z -> %tolower_c(C) when C >= $A, C =< $Z ->
% C + 32; % C + 32;
%tolower_c(C) -> %tolower_c(C) ->
@ -259,26 +258,44 @@ tolower([]) ->
% []. % [].
nodeprep(S) -> nodeprep(S) when length(S) < 1024 ->
stringprep:nodeprep(S). R = stringprep:nodeprep(S),
if
length(R) < 1024 -> R;
true -> error
end;
nodeprep(_) ->
error.
nameprep(S) -> nameprep(S) when length(S) < 1024 ->
stringprep:nameprep(S). R = stringprep:nameprep(S),
if
length(R) < 1024 -> R;
true -> error
end;
nameprep(_) ->
error.
resourceprep(S) -> resourceprep(S) when length(S) < 1024 ->
stringprep:resourceprep(S). R = stringprep:resourceprep(S),
if
length(R) < 1024 -> R;
true -> error
end;
resourceprep(_) ->
error.
jid_tolower(#jid{luser = U, lserver = S, lresource = R}) -> jid_tolower(#jid{luser = U, lserver = S, lresource = R}) ->
{U, S, R}; {U, S, R};
jid_tolower({U, S, R}) -> jid_tolower({U, S, R}) ->
case stringprep:nodeprep(U) of case nodeprep(U) of
error -> error; error -> error;
LUser -> LUser ->
case stringprep:nameprep(S) of case nameprep(S) of
error -> error; error -> error;
LServer -> LServer ->
case stringprep:resourceprep(R) of case resourceprep(R) of
error -> error; error -> error;
LResource -> LResource ->
{LUser, LServer, LResource} {LUser, LServer, LResource}
@ -288,20 +305,20 @@ jid_tolower({U, S, R}) ->
jid_remove_resource(#jid{} = JID) -> jid_remove_resource(#jid{} = JID) ->
JID#jid{resource = "", lresource = ""}; JID#jid{resource = "", lresource = ""};
jid_remove_resource({U, S, R}) -> jid_remove_resource({U, S, _R}) ->
{U, S, ""}. {U, S, ""}.
jid_replace_resource(JID, Resource) -> jid_replace_resource(JID, Resource) ->
case stringprep:resourceprep(Resource) of case resourceprep(Resource) of
error -> error; error -> error;
LResource -> LResource ->
JID#jid{resource = Resource, lresource = LResource} JID#jid{resource = Resource, lresource = LResource}
end. end.
get_iq_namespace({xmlelement, Name, Attrs, Els}) when Name == "iq" -> get_iq_namespace({xmlelement, Name, _Attrs, Els}) when Name == "iq" ->
case xml:remove_cdata(Els) of case xml:remove_cdata(Els) of
[{xmlelement, Name2, Attrs2, Els2}] -> [{xmlelement, _Name2, Attrs2, _Els2}] ->
xml:get_attr_s("xmlns", Attrs2); xml:get_attr_s("xmlns", Attrs2);
_ -> _ ->
"" ""
@ -362,7 +379,7 @@ iq_to_xml({iq, ID, Type, _, SubEl}) ->
parse_xdata_submit(El) -> parse_xdata_submit(El) ->
{xmlelement, Name, Attrs, Els} = El, {xmlelement, _Name, Attrs, Els} = El,
case xml:get_attr_s("type", Attrs) of case xml:get_attr_s("type", Attrs) of
"submit" -> "submit" ->
lists:reverse(parse_xdata_fields(Els, [])); lists:reverse(parse_xdata_fields(Els, []));
@ -391,7 +408,7 @@ parse_xdata_fields([_ | Els], Res) ->
parse_xdata_values([], Res) -> parse_xdata_values([], Res) ->
Res; Res;
parse_xdata_values([{xmlelement, Name, Attrs, SubEls} | Els], Res) -> parse_xdata_values([{xmlelement, Name, _Attrs, SubEls} | Els], Res) ->
case Name of case Name of
"value" -> "value" ->
Val = xml:get_cdata(SubEls), Val = xml:get_cdata(SubEls),
@ -454,7 +471,7 @@ decode1_base64([Sextet1,Sextet2,Sextet3,Sextet4|Rest]) ->
Octet2=(Bits4x6 bsr 8) band 16#ff, Octet2=(Bits4x6 bsr 8) band 16#ff,
Octet3=Bits4x6 band 16#ff, Octet3=Bits4x6 band 16#ff,
[Octet1,Octet2,Octet3|decode_base64(Rest)]; [Octet1,Octet2,Octet3|decode_base64(Rest)];
decode1_base64(CatchAll) -> decode1_base64(_CatchAll) ->
"". "".
d(X) when X >= $A, X =<$Z -> d(X) when X >= $A, X =<$Z ->