You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@xerces.apache.org by kn...@apache.org on 2002/07/18 22:05:31 UTC
cvs commit: xml-xerces/c/src/xercesc/util PlatformUtils.cpp PlatformUtils.hpp TransService.cpp TransService.hpp XMLUni.cpp XMLUni.hpp
knoaman 2002/07/18 13:05:31
Modified: c/src/xercesc/util PlatformUtils.cpp PlatformUtils.hpp
TransService.cpp TransService.hpp XMLUni.cpp
XMLUni.hpp
Log:
Add a new feature to control strict IANA encoding name.
Revision Changes Path
1.2 +25 -0 xml-xerces/c/src/xercesc/util/PlatformUtils.cpp
Index: PlatformUtils.cpp
===================================================================
RCS file: /home/cvs/xml-xerces/c/src/xercesc/util/PlatformUtils.cpp,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- PlatformUtils.cpp 1 Feb 2002 22:22:11 -0000 1.1
+++ PlatformUtils.cpp 18 Jul 2002 20:05:31 -0000 1.2
@@ -56,8 +56,11 @@
/*
* $Log$
- * Revision 1.1 2002/02/01 22:22:11 peiyongz
- * Initial revision
+ * Revision 1.2 2002/07/18 20:05:31 knoaman
+ * Add a new feature to control strict IANA encoding name.
+ *
+ * Revision 1.1.1.1 2002/02/01 22:22:11 peiyongz
+ * sane_include
*
* Revision 1.16 2001/10/25 21:52:28 peiyongz
* XMLDeleterFor related functions and data are removed.
@@ -356,5 +359,27 @@
bool XMLPlatformUtils::isNELRecognized() {
return XMLReader::isNELRecognized();
+}
+
+// ---------------------------------------------------------------------------
+// XMLPlatformUtils: IANA Encoding checking setting
+// ---------------------------------------------------------------------------
+void XMLPlatformUtils::strictIANAEncoding(const bool state) {
+
+ //Make sure initialize has been called
+ if (gInitFlag == 0) {
+ return;
+ }
+
+ fgTransService->strictIANAEncoding(state);
+}
+
+
+bool XMLPlatformUtils::isStrictIANAEncoding() {
+
+ if (gInitFlag)
+ return fgTransService->isStrictIANAEncoding();
+
+ return false;
}
1.4 +21 -1 xml-xerces/c/src/xercesc/util/PlatformUtils.hpp
Index: PlatformUtils.hpp
===================================================================
RCS file: /home/cvs/xml-xerces/c/src/xercesc/util/PlatformUtils.hpp,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- PlatformUtils.hpp 19 Jun 2002 22:00:12 -0000 1.3
+++ PlatformUtils.hpp 18 Jul 2002 20:05:31 -0000 1.4
@@ -578,6 +578,26 @@
static bool isNELRecognized();
//@}
+ /** @name Strict IANA Encoding Checking */
+ //@{
+ /**
+ * This function enables/disables strict IANA encoding names checking.
+ *
+ * The strict checking is disabled by default.
+ *
+ * @param state If true, a strict IANA encoding name check is performed,
+ * otherwise, no checking.
+ *
+ */
+ static void strictIANAEncoding(const bool state);
+
+ /**
+ * Returns whether a strict IANA encoding name check is enabled or
+ * disabled.
+ */
+ static bool isStrictIANAEncoding();
+ //@}
+
private :
/** @name Private static methods */
1.5 +28 -2 xml-xerces/c/src/xercesc/util/TransService.cpp
Index: TransService.cpp
===================================================================
RCS file: /home/cvs/xml-xerces/c/src/xercesc/util/TransService.cpp,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- TransService.cpp 10 Jun 2002 20:14:00 -0000 1.4
+++ TransService.cpp 18 Jul 2002 20:05:31 -0000 1.5
@@ -74,6 +74,7 @@
#include <xercesc/util/XMLUniDefs.hpp>
#include <xercesc/util/XMLUni.hpp>
#include <xercesc/util/TransENameMap.hpp>
+#include <xercesc/util/EncodingValidator.hpp>
@@ -137,7 +138,7 @@
{
chLatin_I, chLatin_B, chLatin_M, chNull
};
-
+static bool gStrictIANAEncoding = false;
// ---------------------------------------------------------------------------
@@ -186,6 +187,18 @@
, const unsigned int blockSize)
{
//
+ // If strict IANA encoding flag is set, validate encoding name
+ //
+ if (gStrictIANAEncoding)
+ {
+ if (!EncodingValidator::instance()->isValidEncoding(encodingName))
+ {
+ resValue = XMLTransService::UnsupportedEncoding;
+ return 0;
+ }
+ }
+
+ //
// First try to find it in our list of mappings to intrinsically
// supported encodings. We have to upper case the passed encoding
// name because we use a hash table and we stored all our mappings
@@ -521,4 +534,17 @@
//
gMappings->put((void*)XMLUni::fgWin1252EncodingString, new ENameMapFor<XMLWin1252Transcoder>(XMLUni::fgWin1252EncodingString));
+}
+
+// ---------------------------------------------------------------------------
+// XLMTransService: IANA encoding setting
+// ---------------------------------------------------------------------------
+void XMLTransService::strictIANAEncoding(const bool newState)
+{
+ gStrictIANAEncoding = newState;
+}
+
+bool XMLTransService::isStrictIANAEncoding()
+{
+ return gStrictIANAEncoding;
}
1.3 +9 -0 xml-xerces/c/src/xercesc/util/TransService.hpp
Index: TransService.hpp
===================================================================
RCS file: /home/cvs/xml-xerces/c/src/xercesc/util/TransService.hpp,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- TransService.hpp 9 Apr 2002 15:44:00 -0000 1.2
+++ TransService.hpp 18 Jul 2002 20:05:31 -0000 1.3
@@ -56,6 +56,9 @@
/*
* $Log$
+ * Revision 1.3 2002/07/18 20:05:31 knoaman
+ * Add a new feature to control strict IANA encoding name.
+ *
* Revision 1.2 2002/04/09 15:44:00 knoaman
* Add lower case string support.
*
@@ -253,6 +256,12 @@
XMLTransService(const XMLTransService&);
void operator=(const XMLTransService&);
+ // -----------------------------------------------------------------------
+ // Hidden method to enable/disable strict IANA encoding check
+ // Caller: XMLPlatformUtils
+ // -----------------------------------------------------------------------
+ void strictIANAEncoding(const bool newState);
+ bool isStrictIANAEncoding();
// -----------------------------------------------------------------------
// Hidden init method for platform utils to call
1.15 +16 -1 xml-xerces/c/src/xercesc/util/XMLUni.cpp
Index: XMLUni.cpp
===================================================================
RCS file: /home/cvs/xml-xerces/c/src/xercesc/util/XMLUni.cpp,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -r1.14 -r1.15
--- XMLUni.cpp 11 Jul 2002 18:32:42 -0000 1.14
+++ XMLUni.cpp 18 Jul 2002 20:05:31 -0000 1.15
@@ -1031,6 +1031,21 @@
, chLatin_s, chLatin_e, chNull
};
+//Xerces: http://apache.org/xml/features/validation/strict-IANAEncoding
+const XMLCh XMLUni::fgXercesStrictIANAEncoding[] =
+{
+ chLatin_h, chLatin_t, chLatin_t, chLatin_p, chColon, chForwardSlash
+ , chForwardSlash, chLatin_a, chLatin_p, chLatin_a, chLatin_c, chLatin_h
+ , chLatin_e, chPeriod, chLatin_o, chLatin_r, chLatin_g, chForwardSlash
+ , chLatin_x, chLatin_m, chLatin_l, chForwardSlash, chLatin_f, chLatin_e
+ , chLatin_a, chLatin_t, chLatin_u, chLatin_r, chLatin_e, chLatin_s
+ , chForwardSlash, chLatin_v, chLatin_a, chLatin_l, chLatin_i, chLatin_d
+ , chLatin_a, chLatin_t, chLatin_i, chLatin_o, chLatin_n, chForwardSlash
+ , chLatin_s, chLatin_t, chLatin_r, chLatin_i, chLatin_c, chLatin_t, chDash
+ , chLatin_I, chLatin_A, chLatin_N, chLatin_A, chLatin_E, chLatin_n, chLatin_c
+ , chLatin_o, chLatin_d, chLatin_i, chLatin_n, chLatin_g, chNull
+};
+
//Introduced in DOM Level 3
const XMLCh XMLUni::fgDOMCanonicalForm[] =
1.13 +2 -1 xml-xerces/c/src/xercesc/util/XMLUni.hpp
Index: XMLUni.hpp
===================================================================
RCS file: /home/cvs/xml-xerces/c/src/xercesc/util/XMLUni.hpp,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -r1.12 -r1.13
--- XMLUni.hpp 11 Jul 2002 18:32:42 -0000 1.12
+++ XMLUni.hpp 18 Jul 2002 20:05:31 -0000 1.13
@@ -230,6 +230,7 @@
static const XMLCh fgXercesUserAdoptsDOMDocument[];
static const XMLCh fgXercesCacheGrammarFromParse[];
static const XMLCh fgXercesUseCachedGrammarInParse[];
+ static const XMLCh fgXercesStrictIANAEncoding[];
// SAX2 features/properties names
static const XMLCh fgSAX2CoreValidation[];
---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-cvs-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-cvs-help@xml.apache.org