From 06e315e4a095bb5b32ccff37b4e6283e6b714e0c Mon Sep 17 00:00:00 2001 From: cantor Date: Fri, 27 Mar 2009 17:27:04 +0000 Subject: [PATCH] URL encode exception properties for XML-safe transport. git-svn-id: https://svn.middleware.georgetown.edu/cpp-xmltooling/branches/REL_1@575 de75baf8-a10c-0410-a50a-987c0e22f00f --- xmltooling/exceptions.cpp | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/xmltooling/exceptions.cpp b/xmltooling/exceptions.cpp index ea8aa40..170f9d9 100644 --- a/xmltooling/exceptions.cpp +++ b/xmltooling/exceptions.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2001-2007 Internet2 + * Copyright 2001-2009 Internet2 * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -249,9 +249,10 @@ string XMLToolingException::toString() const const char* msg=getMessage(); if (msg) xml_encode(xml, "", msg, ""); + const URLEncoder* encoder = XMLToolingConfig::getConfig().getURLEncoder(); for (map::const_iterator i=m_params.begin(); i!=m_params.end(); i++) { xml_encode(xml, "", i->second.c_str(), ""); + xml_encode(xml, ">", encoder->encode(i->second.c_str()).c_str(), ""); } xml+=""; return xml; @@ -295,13 +296,16 @@ XMLToolingException* XMLToolingException::fromStream(std::istream& in) excep->setMessage(m.get()); } + const URLEncoder* encoder = XMLToolingConfig::getConfig().getURLEncoder(); child=XMLHelper::getFirstChildElement(root,XMLTOOLING_NS,param); while (child && child->hasChildNodes()) { auto_ptr_char n(child->getAttributeNS(NULL,name)); - char* v=toUTF8(child->getFirstChild()->getNodeValue()); - if (n.get() && v) - excep->addProperty(n.get(), v); - delete[] v; + char* encoded = XMLString::transcode(child->getFirstChild()->getNodeValue()); + if (n.get() && encoded) { + encoder->decode(encoded); + excep->addProperty(n.get(), encoded); + } + XMLString::release(&encoded); child=XMLHelper::getNextSiblingElement(child,XMLTOOLING_NS,param); } -- 2.1.4