bug fixed: " handling

This commit is contained in:
Pascal Brisset
2008-10-17 15:21:55 +00:00
parent ef803b018a
commit b156f05ecf
4 changed files with 18 additions and 3 deletions
+11
View File
@@ -229,3 +229,14 @@ let parse_file = fun ?(noprovedtd = false) file ->
let digest = fun xml ->
Digest.string (Xml.to_string xml)
let predefined_general_entities =
[ Str.regexp "&", "&";
Str.regexp """, "\"" ]
let display_entities = fun s ->
List.fold_right
(fun (regexp, displayed_as) r -> Str.global_replace regexp displayed_as r)
predefined_general_entities
s
+1
View File
@@ -69,3 +69,4 @@ val parse_file : ?noprovedtd:bool -> string -> Xml.xml
val digest : Xml.xml -> Digest.t
(** Returns the MD5 digest of an XML tree (c.f. Digest module of std library) *)
val display_entities : string -> string
+5 -2
View File
@@ -73,11 +73,14 @@ let parse_file = fun file ->
| D, '"' -> copy_and_continue D'
| D, _ -> copy_and_continue D
(* Inside a quoted string *)
| D', '"' -> copy_and_continue D
| D', '\\' -> copy_and_continue D''
| D', '\\' -> automata D''
| D', _ -> copy_and_continue D'
| D'', _ -> copy_and_continue D'
(* Inside a quoted string, just after a \ (backslash) *)
| D'', '"' -> Buffer.add_string buff """; automata D'
| D'', _ -> Buffer.add_char buff '\\'; copy_and_continue D'
| E, '>' -> replace_and_continue A
| E, _ -> copy_and_continue D
+1 -1
View File
@@ -70,7 +70,7 @@ let parse_element = fun prefix s ->
match Xml.tag s with
"define" -> begin
try
define (prefix^ExtXml.attrib s "name") (ExtXml.attrib s "value");
define (prefix^ExtXml.attrib s "name") (ExtXml.display_entities (ExtXml.attrib s "value"));
define_integer (prefix^(ExtXml.attrib s "name")) (ExtXml.float_attrib s "value") (ExtXml.int_attrib s "integer");
with _ -> ();
end