rrichards Fri Jul 21 00:57:14 2006 UTC
Modified files:
/php-src/ext/xmlreader php_xmlreader.c
Log:
unicode support for handling filenames
http://cvs.php.net/viewvc.cgi/php-src/ext/xmlreader/php_xmlreader.c?r1=1.34&r2=1.35&diff_format=u
Index: php-src/ext/xmlreader/php_xmlreader.c
diff -u php-src/ext/xmlreader/php_xmlreader.c:1.34
php-src/ext/xmlreader/php_xmlreader.c:1.35
--- php-src/ext/xmlreader/php_xmlreader.c:1.34 Wed Jul 19 18:32:19 2006
+++ php-src/ext/xmlreader/php_xmlreader.c Fri Jul 21 00:57:14 2006
@@ -16,7 +16,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: php_xmlreader.c,v 1.34 2006/07/19 18:32:19 rrichards Exp $ */
+/* $Id: php_xmlreader.c,v 1.35 2006/07/21 00:57:14 rrichards Exp $ */
#ifdef HAVE_CONFIG_H
#include "config.h"
@@ -505,9 +505,16 @@
xmlreader_object *intern;
xmlRelaxNGPtr schema = NULL;
char *source;
+ zend_uchar source_type = IS_STRING;
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s!", &source,
&source_len) == FAILURE) {
- return;
+ if (type == XMLREADER_LOAD_FILE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "t!",
&source, &source_len, &source_type) == FAILURE) {
+ return;
+ }
+ } else {
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s!",
&source, &source_len) == FAILURE) {
+ return;
+ }
}
if (source != NULL && !source_len) {
@@ -520,10 +527,18 @@
intern = (xmlreader_object *)zend_object_store_get_object(id TSRMLS_CC);
if (intern && intern->ptr) {
if (source) {
+ if (source_type == IS_UNICODE) {
+ if (php_stream_path_encode(NULL, &source,
&source_len, (UChar*)source, source_len, REPORT_ERRORS, NULL) == FAILURE) {
+ RETURN_FALSE;
+ }
+ }
schema = _xmlreader_get_relaxNG(source, source_len,
type, NULL, NULL TSRMLS_CC);
if (schema) {
retval =
xmlTextReaderRelaxNGSetSchema(intern->ptr, schema);
}
+ if (source_type == IS_UNICODE) {
+ efree(source);
+ }
} else {
/* unset the associated relaxNG context and schema if
one exists */
retval = xmlTextReaderRelaxNGSetSchema(intern->ptr,
NULL);
@@ -902,6 +917,7 @@
{
zval *id;
int source_len = 0, encoding_len = 0;
+ zend_uchar source_type;
long options = 0;
xmlreader_object *intern = NULL;
char *source, *valid_file = NULL;
@@ -913,7 +929,7 @@
orig_runtime_conv = ZEND_U_CONVERTER(UG(runtime_encoding_conv));
UG(runtime_encoding_conv) = UG(utf8_conv);
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|s!l", &source,
&source_len, &encoding, &encoding_len, &options) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "t|s!l", &source,
&source_len, &source_type, &encoding, &encoding_len, &options) == FAILURE) {
UG(runtime_encoding_conv) = orig_runtime_conv;
return;
}
@@ -935,12 +951,22 @@
RETURN_FALSE;
}
+ if (source_type == IS_UNICODE) {
+ if (php_stream_path_encode(NULL, &source, &source_len,
(UChar*)source, source_len, REPORT_ERRORS, NULL) == FAILURE) {
+ RETURN_FALSE;
+ }
+ }
+
valid_file = _xmlreader_get_valid_file_path(source, resolved_path,
MAXPATHLEN TSRMLS_CC);
if (valid_file) {
reader = xmlReaderForFile(valid_file, encoding, options);
}
+ if (source_type == IS_UNICODE) {
+ efree(source);
+ }
+
if (reader == NULL) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unable to open
source data");
RETURN_FALSE;
@@ -1001,8 +1027,9 @@
int source_len = 0, retval = -1;
xmlreader_object *intern;
char *source;
+ zend_uchar source_type;
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s!", &source,
&source_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "t!", &source,
&source_len, &source_type) == FAILURE) {
return;
}
@@ -1015,8 +1042,17 @@
intern = (xmlreader_object *)zend_object_store_get_object(id TSRMLS_CC);
if (intern && intern->ptr) {
+ if (source_type == IS_UNICODE) {
+ if (php_stream_path_encode(NULL, &source, &source_len,
(UChar*)source, source_len, REPORT_ERRORS, NULL) == FAILURE) {
+ RETURN_FALSE;
+ }
+ }
retval = xmlTextReaderSchemaValidate(intern->ptr, source);
+ if (source_type == IS_UNICODE) {
+ efree(source);
+ }
+
if (retval == 0) {
RETURN_TRUE;
}
--
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php