rrichards               Mon Sep 15 08:29:53 2003 EDT

  Modified files:              
    /php-src/ext/dom    document.c 
  Log:
  validate encoding against valid handlers
  
Index: php-src/ext/dom/document.c
diff -u php-src/ext/dom/document.c:1.24 php-src/ext/dom/document.c:1.25
--- php-src/ext/dom/document.c:1.24     Mon Sep  8 14:28:35 2003
+++ php-src/ext/dom/document.c  Mon Sep 15 08:29:52 2003
@@ -17,7 +17,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: document.c,v 1.24 2003/09/08 18:28:35 rrichards Exp $ */
+/* $Id: document.c,v 1.25 2003/09/15 12:29:52 rrichards Exp $ */
 
 #ifdef HAVE_CONFIG_H
 #include "config.h"
@@ -250,15 +250,17 @@
 int dom_document_encoding_write(dom_object *obj, zval *newval TSRMLS_DC)
 {
        xmlDoc *docp;
-       int charset;
+       xmlCharEncodingHandlerPtr handler;
 
        docp = (xmlDocPtr) dom_object_get_node(obj);
-       if (docp->encoding != NULL) {
-               xmlFree((xmlChar *)docp->encoding);
-       }
 
-    charset = (int)xmlParseCharEncoding((const xmlChar *) Z_STRVAL_P(newval));
-    if (charset > 0) {
+       handler = xmlFindCharEncodingHandler(Z_STRVAL_P(newval));
+
+    if (handler != NULL) {
+               xmlCharEncCloseFunc(handler);
+               if (docp->encoding != NULL) {
+                       xmlFree((xmlChar *)docp->encoding);
+               }
                docp->encoding = xmlStrdup((const xmlChar *) Z_STRVAL_P(newval));
                return SUCCESS;
     } else {

-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to