summaryrefslogtreecommitdiff
path: root/ext/xmlreader/php_xmlreader.c
diff options
context:
space:
mode:
authorRob Richards <rrichards@php.net>2006-07-21 00:57:14 +0000
committerRob Richards <rrichards@php.net>2006-07-21 00:57:14 +0000
commitf7575a538eda83d9e93d6df9ab80fe073aa95212 (patch)
tree1bf12a24cfb662524d92ec6bcaca902f79d7ee45 /ext/xmlreader/php_xmlreader.c
parent40b4c60b9a4929e224868bb6f5b4b02c15e7f50a (diff)
downloadphp-git-f7575a538eda83d9e93d6df9ab80fe073aa95212.tar.gz
unicode support for handling filenames
Diffstat (limited to 'ext/xmlreader/php_xmlreader.c')
-rw-r--r--ext/xmlreader/php_xmlreader.c44
1 files changed, 40 insertions, 4 deletions
diff --git a/ext/xmlreader/php_xmlreader.c b/ext/xmlreader/php_xmlreader.c
index c23a516e86..48913377c7 100644
--- a/ext/xmlreader/php_xmlreader.c
+++ b/ext/xmlreader/php_xmlreader.c
@@ -505,9 +505,16 @@ static void php_xmlreader_set_relaxng_schema(INTERNAL_FUNCTION_PARAMETERS, int t
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 @@ static void php_xmlreader_set_relaxng_schema(INTERNAL_FUNCTION_PARAMETERS, int t
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 @@ PHP_METHOD(xmlreader, open)
{
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 @@ PHP_METHOD(xmlreader, open)
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 @@ PHP_METHOD(xmlreader, open)
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 @@ PHP_METHOD(xmlreader, setSchema)
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 @@ PHP_METHOD(xmlreader, setSchema)
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;
}