Skip to content

Commit 0001bdf

Browse files
author
Martin Cox
authored
Merge pull request #751 from llelf/sec1
Straighten security
2 parents 09975fe + 5ebab64 commit 0001bdf

File tree

2 files changed

+9
-18
lines changed

2 files changed

+9
-18
lines changed

src/yz_wm_search.erl

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,6 @@
2323
-include("yokozuna.hrl").
2424
-include_lib("webmachine/include/webmachine.hrl").
2525

26-
-define(YZ_HEAD_FPROF, "yz-fprof").
27-
2826
-record(ctx, {security %% security context
2927
}).
3028

@@ -121,8 +119,6 @@ search(Req, S) ->
121119
search(Req, S, Params).
122120

123121
search(Req, S, Params) ->
124-
{FProf, FProfFile} = check_for_fprof(Req),
125-
?IF(FProf, fprof:trace(start, FProfFile)),
126122
T1 = os:timestamp(),
127123
Index = list_to_binary(wrq:path_info(index, Req)),
128124
try
@@ -155,26 +151,13 @@ search(Req, S, Params) ->
155151
ErrReq2 = wrq:set_resp_header("Content-Type", "text/plain",
156152
ErrReq),
157153
{{halt, Code}, ErrReq2, S}
158-
after
159-
?IF(FProf, fprof_analyse(FProfFile))
160154
end.
161155

162156
%% @doc Solr returns as chunked but not going to return as chunked from
163157
%% Yokozuna.
164158
scrub_headers(RespHeaders) when is_list(RespHeaders) ->
165159
lists:keydelete("Transfer-Encoding", 1, RespHeaders).
166160

167-
check_for_fprof(Req) ->
168-
case wrq:get_req_header(?YZ_HEAD_FPROF, Req) of
169-
undefined -> {false, none};
170-
File -> {true, File}
171-
end.
172-
173-
fprof_analyse(FileName) ->
174-
fprof:trace(stop),
175-
fprof:profile(file, FileName),
176-
fprof:analyse([{dest, FileName ++ ".analysis"}, {cols, 120}]).
177-
178161
-spec resource_exists(term(), term()) -> {boolean(), term(), term()}.
179162
resource_exists(RD, Context) ->
180163
IndexName = list_to_binary(wrq:path_info(index, RD)),

src/yz_xml_extractor.erl

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,12 @@ extract(Value, Opts) ->
5656
extract_fields(Value, #state{field_separator=Sep}).
5757

5858
extract_fields(Data, State) ->
59-
Options = [{event_fun, fun sax_cb/3}, {event_state, State}],
59+
Options = [
60+
{file_type, normal},
61+
skip_external_dtd,
62+
{event_fun, fun sax_cb/3},
63+
{event_state, State}
64+
],
6065
case xmerl_sax_parser:stream(Data, Options) of
6166
{ok, State2, _Rest} ->
6267
State2#state.fields;
@@ -88,6 +93,9 @@ sax_cb({characters, Value}, _Location, S) ->
8893
Field = {Name, unicode:characters_to_binary(Value)},
8994
S#state{fields = [Field|S#state.fields]};
9095

96+
sax_cb({externalEntityDecl,_,_,_}, _, _State) ->
97+
throw(external_entity_disarmed);
98+
9199
sax_cb(_Event, _Location, State) ->
92100
State.
93101

0 commit comments

Comments
 (0)