Added: xdebug/trunk/tests/bug00475.phpt
===================================================================
--- xdebug/trunk/tests/bug00475.phpt (rev 0)
+++ xdebug/trunk/tests/bug00475.phpt 2010-04-05 13:17:52 UTC (rev 3251)
@@ -0,0 +1,44 @@
+--TEST--
+Test for bug #475: Property names with null chars are not sent fully to the client.
+--FILE--
+ "Value", "example" => "value\0key" );
+var_dump( $a );
+NOWDOC;
+
+$commands = array(
+ 'step_into',
+ 'breakpoint_set -t line -n 3',
+ 'run',
+ 'property_get -n a',
+ 'detach'
+);
+
+dbgpRun( $data, $commands );
+?>
+--EXPECT--
+
+
+
+-> step_into -i 1
+
+
+
+-> breakpoint_set -i 2 -t line -n 3
+
+
+
+-> run -i 3
+
+
+
+-> property_get -i 4 -n a
+
+
+
+-> detach -i 5
+
+
Modified: xdebug/trunk/xdebug_var.c
===================================================================
--- xdebug/trunk/xdebug_var.c 2010-04-05 13:11:02 UTC (rev 3250)
+++ xdebug/trunk/xdebug_var.c 2010-04-05 13:17:52 UTC (rev 3251)
@@ -513,7 +513,9 @@
xdebug_xml_node *parent;
xdebug_xml_node *node;
xdebug_var_export_options *options;
- char *name = NULL, *parent_name = NULL, *full_name = NULL;
+ char *name = NULL, *parent_name = NULL;
+ int name_len = 0;
+ xdebug_str full_name = { 0, 0, NULL };
#if !defined(PHP_VERSION_ID) || PHP_VERSION_ID < 50300
TSRMLS_FETCH();
#endif
@@ -529,33 +531,37 @@
node = xdebug_xml_node_init("property");
if (hash_key->nKeyLength != 0) {
- name = xdstrdup(hash_key->arKey);
- if (!parent_name) {
- full_name = NULL;
- } else if (parent_name[0] != '$') {
- full_name = xdebug_sprintf("$%s['%s']", parent_name, name);
- } else {
- full_name = xdebug_sprintf("%s['%s']", parent_name, name);
+ name = xdstrndup(hash_key->arKey, hash_key->nKeyLength);
+ name_len = hash_key->nKeyLength - 1;
+ if (parent_name) {
+ if (parent_name[0] != '$') {
+ xdebug_str_addl(&full_name, "$", 1, 0);
+ }
+ xdebug_str_add(&full_name, parent_name, 0);
+ xdebug_str_addl(&full_name, "['", 2, 0);
+ xdebug_str_addl(&full_name, name, name_len, 0);
+ xdebug_str_addl(&full_name, "']", 2, 0);
}
} else {
name = xdebug_sprintf("%ld", hash_key->h);
- if (!parent_name) {
- full_name = NULL;
- } else if (parent_name[0] != '$') {
- full_name = xdebug_sprintf("$%s[%s]", parent_name, name);
- } else {
- full_name = xdebug_sprintf("%s[%s]", parent_name, name);
+ name_len = strlen(name);
+ if (parent_name) {
+ if (parent_name[0] != '$') {
+ xdebug_str_add(&full_name, xdebug_sprintf("$%s[%s]", parent_name, name), 1);
+ } else {
+ xdebug_str_add(&full_name, xdebug_sprintf("%s[%s]", parent_name, name), 1);
+ }
}
}
- xdebug_xml_add_attribute_ex(node, "name", name, 0, 1);
- if (full_name) {
- xdebug_xml_add_attribute_ex(node, "fullname", full_name, 0, 1);
+ xdebug_xml_add_attribute_exl(node, "name", 4, name, name_len, 0, 1);
+ if (full_name.l) {
+ xdebug_xml_add_attribute_exl(node, "fullname", 8, full_name.d, full_name.l, 0, 1);
}
xdebug_xml_add_attribute_ex(node, "address", xdebug_sprintf("%ld", (long) *zv), 0, 1);
xdebug_xml_add_child(parent, node);
- xdebug_var_export_xml_node(zv, full_name, node, options, level + 1 TSRMLS_CC);
+ xdebug_var_export_xml_node(zv, full_name.d, node, options, level + 1 TSRMLS_CC);
}
options->runtime[level].current_element_nr++;
return 0;
Modified: xdebug/trunk/xdebug_xml.c
===================================================================
--- xdebug/trunk/xdebug_xml.c 2010-04-05 13:11:02 UTC (rev 3250)
+++ xdebug/trunk/xdebug_xml.c 2010-04-05 13:17:52 UTC (rev 3251)
@@ -30,10 +30,16 @@
int newlen;
xdebug_str_addl(output, " ", 1, 0);
- xdebug_str_add(output, attr->name, 0);
+
+ /* attribute name */
+ tmp = xdebug_xmlize(attr->name, attr->name_len, &newlen);
+ xdebug_str_addl(output, tmp, newlen, 0);
+ efree(tmp);
+
+ /* attribute value */
xdebug_str_addl(output, "=\"", 2, 0);
if (attr->value) {
- tmp = xdebug_xmlize(attr->value, strlen(attr->value), &newlen);
+ tmp = xdebug_xmlize(attr->value, attr->value_len, &newlen);
xdebug_str_add(output, tmp, 0);
efree(tmp);
}
@@ -105,7 +111,7 @@
return xml;
}
-void xdebug_xml_add_attribute_ex(xdebug_xml_node* xml, char *attribute, char *value, int free_name, int free_value)
+void xdebug_xml_add_attribute_exl(xdebug_xml_node* xml, char *attribute, int attribute_len, char *value, int value_len, int free_name, int free_value)
{
xdebug_xml_attribute *attr = xdmalloc(sizeof (xdebug_xml_attribute));
xdebug_xml_attribute **ptr;
@@ -113,6 +119,8 @@
/* Init structure */
attr->name = attribute;
attr->value = value;
+ attr->name_len = attribute_len;
+ attr->value_len = value_len;
attr->next = NULL;
attr->free_name = free_name;
attr->free_value = free_value;
Modified: xdebug/trunk/xdebug_xml.h
===================================================================
--- xdebug/trunk/xdebug_xml.h 2010-04-05 13:11:02 UTC (rev 3250)
+++ xdebug/trunk/xdebug_xml.h 2010-04-05 13:17:52 UTC (rev 3251)
@@ -29,6 +29,8 @@
{
char *name;
char *value;
+ int name_len;
+ int value_len;
struct _xdebug_xml_attribute *next;
int free_name;
int free_value;
@@ -54,11 +56,12 @@
};
-#define xdebug_xml_node_init(t) xdebug_xml_node_init_ex((t), 0)
-#define xdebug_xml_add_attribute(x,a,v) xdebug_xml_add_attribute_ex((x), (a), (v), 0, 0);
+#define xdebug_xml_node_init(t) xdebug_xml_node_init_ex((t), 0)
+#define xdebug_xml_add_attribute_ex(x,a,v,fa,fv) { char *ta = (a), *tv = (v); xdebug_xml_add_attribute_exl((x), (ta), strlen((ta)), (tv), strlen((tv)), fa, fv); }
+#define xdebug_xml_add_attribute(x,a,v) xdebug_xml_add_attribute_ex((x), (a), (v), 0, 0);
xdebug_xml_node *xdebug_xml_node_init_ex(char *tag, int free_tag);
-void xdebug_xml_add_attribute_ex(xdebug_xml_node* xml, char *attribute, char *value, int free_name, int free_value);
+void xdebug_xml_add_attribute_exl(xdebug_xml_node* xml, char *attribute, int attribute_len, char *value, int varlue_len, int free_name, int free_value);
void xdebug_xml_add_child(xdebug_xml_node *xml, xdebug_xml_node *child);
void xdebug_xml_add_text_ex(xdebug_xml_node *xml, char *text, int length, int free_text, int encode);