From 07b89f0a77a8099cda7b53b4babdf9511966d8fd Mon Sep 17 00:00:00 2001 From: Stefano Zacchiroli Date: Fri, 4 Feb 2005 15:04:53 +0000 Subject: [PATCH] escape exception name and arguments embedded in root element attributes to avoid non well formed xml documents to be generated --- helm/http_getter/Makefile | 2 +- helm/http_getter/main.ml | 7 +++++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/helm/http_getter/Makefile b/helm/http_getter/Makefile index 94668953e..f5d435564 100644 --- a/helm/http_getter/Makefile +++ b/helm/http_getter/Makefile @@ -1,7 +1,7 @@ VERSION = 0.3.0 NAME = http_getter -REQUIRES = helm-getter helm-logger helm-registry +REQUIRES = helm-getter helm-logger helm-registry netstring COMMONOPTS = -package "$(REQUIRES)" -pp camlp4o -thread OCAMLFIND = ocamlfind OCAMLC = $(OCAMLFIND) ocamlc -g $(COMMONOPTS) diff --git a/helm/http_getter/main.ml b/helm/http_getter/main.ml index 176383615..640584e63 100644 --- a/helm/http_getter/main.ml +++ b/helm/http_getter/main.ml @@ -90,13 +90,16 @@ let parse_rdf_class (req: Http_types.request) = | "backward" -> `Backward | c -> raise (Bad_request ("Invalid RDF class: " ^ c)) +let xml_escape = Netencoding.Html.encode ~in_enc:`Enc_utf8 () + let html_tag ?exn () = let xml_decl = "\n" in match exn with - | Some (exn, value) -> + | Some (exn, arg) -> + let (exn, arg) = (xml_escape exn, xml_escape arg) in sprintf "%s\n" - xml_decl xhtml_ns helm_ns exn value + xml_decl xhtml_ns helm_ns exn arg | None -> sprintf "%s\n" xml_decl xhtml_ns helm_ns -- 2.39.2