Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merge 2.9 into 3.0 #754

Open
wants to merge 8 commits into
base: develop-3.0
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 0 additions & 17 deletions src/yz_wm_search.erl
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,6 @@
-include("yokozuna.hrl").
-include_lib("webmachine/include/webmachine.hrl").

-define(YZ_HEAD_FPROF, "yz-fprof").

-record(ctx, {security %% security context
}).

Expand Down Expand Up @@ -121,8 +119,6 @@ search(Req, S) ->
search(Req, S, Params).

search(Req, S, Params) ->
{FProf, FProfFile} = check_for_fprof(Req),
?IF(FProf, fprof:trace(start, FProfFile)),
T1 = os:timestamp(),
Index = list_to_binary(wrq:path_info(index, Req)),
try
Expand Down Expand Up @@ -155,26 +151,13 @@ search(Req, S, Params) ->
ErrReq2 = wrq:set_resp_header("Content-Type", "text/plain",
ErrReq),
{{halt, Code}, ErrReq2, S}
after
?IF(FProf, fprof_analyse(FProfFile))
end.

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

check_for_fprof(Req) ->
case wrq:get_req_header(?YZ_HEAD_FPROF, Req) of
undefined -> {false, none};
File -> {true, File}
end.

fprof_analyse(FileName) ->
fprof:trace(stop),
fprof:profile(file, FileName),
fprof:analyse([{dest, FileName ++ ".analysis"}, {cols, 120}]).

-spec resource_exists(term(), term()) -> {boolean(), term(), term()}.
resource_exists(RD, Context) ->
IndexName = list_to_binary(wrq:path_info(index, RD)),
Expand Down
10 changes: 9 additions & 1 deletion src/yz_xml_extractor.erl
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,12 @@ extract(Value, Opts) ->
extract_fields(Value, #state{field_separator=Sep}).

extract_fields(Data, State) ->
Options = [{event_fun, fun sax_cb/3}, {event_state, State}],
Options = [
{file_type, normal},
skip_external_dtd,
{event_fun, fun sax_cb/3},
{event_state, State}
],
case xmerl_sax_parser:stream(Data, Options) of
{ok, State2, _Rest} ->
State2#state.fields;
Expand Down Expand Up @@ -90,6 +95,9 @@ sax_cb({characters, Value}, _Location, S) ->
Field = {Name, unicode:characters_to_binary(Value)},
S#state{fields = [Field|S#state.fields]};

sax_cb({externalEntityDecl,_,_,_}, _, _State) ->
throw(external_entity_disarmed);

sax_cb(_Event, _Location, State) ->
State.

Expand Down