Commit e6e927c3 authored by Kim Nguyễn's avatar Kim Nguyễn
Browse files

Disable external loading of XHTML entities and make expat the default parser.

parent 935e396c
......@@ -28,7 +28,10 @@ let rec push p s =
let p = Expat.external_entity_parser_create p ctx None in
push p s);
try
if Url.is_url s then Expat.parse p (Url.load_url s)
if Url.is_url s then begin
let content = Url.load_url s in
Expat.parse p content
end
else load_from_file p s
with Expat.Expat_error e ->
let msg =
......@@ -46,7 +49,7 @@ let load_expat se ee txt s =
Expat.set_start_element_handler p se;
Expat.set_end_element_handler p ee;
Expat.set_character_data_handler p txt;
ignore (Expat.set_param_entity_parsing p Expat.ALWAYS);
ignore (Expat.set_param_entity_parsing p Expat.NEVER);
push p s
let use () =
......
......@@ -55,7 +55,7 @@ let load_pxp handlers uri =
try
let mgr = create_entity_manager pxp_config (src_of_uri uri) in
process_entity pxp_config
(`Entry_document[`Extend_dtd_fully]) mgr handlers;
(`Entry_document[`Parse_xml_decl]) mgr handlers;
with exn ->
Value.failwith' (Pxp_types.string_of_exn exn)
......
......@@ -2,7 +2,7 @@ let features = ref []
let get_features () =
List.stable_sort (fun (p1, _, _, _) (p2, _, _, _) ->
compare p1 p2
compare p2 p1
) !features
let init_all () = List.iter (fun (_, _, _, f) -> f ()) (List.rev (get_features()))
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment