Commits

Fred T-H committed 6159d32

adding them little guards for parameters

Comments (0)

Files changed (1)

src/chut_webserver.erl

     chut_client:message(From, To, Message),
     chut_client:disconnect(From, H),
     %% we clear the event messages because mochiweb re-uses the same procs
-    %% over and over again in a pool. Otherwise, we leak memory and when the
+    %% over and over again in a pool. Otherwise, memory leaks and when the
     %% listen call gets the right message process, a backlog gets printed to
     %% the user.
     lib:flush_receive(),
     io:format("listen call~n"),
     Params = Req:parse_qs(),
     Nick = proplists:get_value("id", Params),
+    ok = check_params(Req, [Nick], ["id"]),
     {ok,Handler} = chut_client:connect(Nick),
     Msgs = chut_client:listen(Nick,Handler),
     JSON = mochijson2:encode([json_prepare(M) || M <- Msgs]),
     io:format("history call~n"),
     Params = Req:parse_qs(),
     Nick = proplists:get_value("id",Params),
+    ok = check_params(Req, [Nick], ["id"]),
     {ok, Handler} = chut_client:connect(Nick),
     Msgs = chut_client:history(Nick),
     JSON = mochijson2:encode([json_prepare(M) || M <- Msgs]),