You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@santuario.apache.org by bl...@apache.org on 2003/02/20 11:35:10 UTC
cvs commit: xml-security/c/src/utils/unixutils XSECURIResolverGenericUnix.cpp
blautenb 2003/02/20 02:35:10
Modified: c/src/utils/unixutils XSECURIResolverGenericUnix.cpp
Log:
Fix for broken Xerces XMLUri
Revision Changes Path
1.2 +63 -2 xml-security/c/src/utils/unixutils/XSECURIResolverGenericUnix.cpp
Index: XSECURIResolverGenericUnix.cpp
===================================================================
RCS file: /home/cvs/xml-security/c/src/utils/unixutils/XSECURIResolverGenericUnix.cpp,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- XSECURIResolverGenericUnix.cpp 12 Feb 2003 11:21:03 -0000 1.1
+++ XSECURIResolverGenericUnix.cpp 20 Feb 2003 10:35:10 -0000 1.2
@@ -71,6 +71,9 @@
* $Id$
*
* $Log$
+ * Revision 1.2 2003/02/20 10:35:10 blautenb
+ * Fix for broken Xerces XMLUri
+ *
* Revision 1.1 2003/02/12 11:21:03 blautenb
* UNIX generic URI resolver
*
@@ -87,6 +90,7 @@
#include <xercesc/util/BinFileInputStream.hpp>
XSEC_USING_XERCES(XMLString);
+XSEC_USING_XERCES(ArrayJanitor);
#include <xsec/framework/XSECError.hpp>
#include <xsec/utils/unixutils/XSECBinHTTPURIInputStream.hpp>
@@ -112,6 +116,22 @@
};
+#if XERCES_VERSION_MAJOR == 2 && XERCES_VERSION_MINOR < 3
+
+
+static const XMLCh DOTDOT_SLASH[] = {
+
+ XERCES_CPP_NAMESPACE_QUALIFIER chPeriod,
+ XERCES_CPP_NAMESPACE_QUALIFIER chPeriod,
+ XERCES_CPP_NAMESPACE_QUALIFIER chForwardSlash,
+ XERCES_CPP_NAMESPACE_QUALIFIER chNull
+
+};
+
+#endif
+
+
+
XSECURIResolverGenericUnix::XSECURIResolverGenericUnix() :
mp_baseURI(NULL) {
@@ -142,10 +162,39 @@
if (mp_baseURI != NULL) {
XMLUri * turi;
+
+#if XERCES_VERSION_MAJOR == 2 && XERCES_VERSION_MINOR < 3
+
+ // XMLUri relative paths are broken, so we need to strip out ".."
+ XMLCh * b = XMLString::replicate(mp_baseURI);
+ ArrayJanitor<XMLCh> j_b(b);
+ XMLCh * r = XMLString::replicate(uri);
+ ArrayJanitor<XMLCh> j_r(r);
+
+ int index = 0;
+ while (XMLString::startsWith(&(r[index]), DOTDOT_SLASH)) {
+
+ // Strip the last segment of the base
+
+ int lastIndex = XMLString::lastIndexOf(b, XERCES_CPP_NAMESPACE_QUALIFIER chForwardSlash);
+ if (lastIndex > 0)
+ b[lastIndex] = 0;
+
+ index += 3;
+
+ }
+
+ XSECnew(turi, XMLUri(b));
+ Janitor<XMLUri> j_turi(turi);
+ XSECnew(xmluri, XMLUri(turi, &(r[index])));
+
+#else
XSECnew(turi, XMLUri(mp_baseURI));
Janitor<XMLUri> j_turi(turi);
XSECnew(xmluri, XMLUri(turi, uri));
+#endif
+
}
else {
XSECnew(xmluri, XMLUri(uri));
@@ -221,3 +270,15 @@
}
+// -----------------------------------------------------------------------
+// Set a base URI to map any incoming files against
+// -----------------------------------------------------------------------
+
+void XSECURIResolverGenericUnix::setBaseURI(const XMLCh * uri) {
+
+ if (mp_baseURI != NULL)
+ delete[] mp_baseURI;
+
+ mp_baseURI = XMLString::replicate(uri);
+
+}