[xdebug-dev] xdebug xdebug/xdebug_xml.c xdebug/xdebug_var.c - fix xml attributes that contain xml entities

From: Shane Caraveo <shane[@]caraveo.com>
Date: Mon, 31 Jan 2005 00:24:34 +0100

Date: Mon Jan 31 00:24:34 CET 2005
User: Shane Caraveo
Directory: xdebug

Log Message:
[1.0]
- fix xml attributes that contain xml entities
- escape single quotes in values

The breakage was found when trying to debug a soap app, and looking at _xmlEntities in SOAP/Base.php

Modified files:
           xdebug/xdebug_xml.c (version: 1.7)
           xdebug/xdebug_var.c (version: 1.56)

[FILE: /xdebug/xdebug_xml.c]

===================================================================
RCS file: cvstemp,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- xdebug/xdebug_xml.c:1.6 Mon Aug 02 20:04:34 2004 GMT
+++ xdebug/xdebug_xml.c Sun Jan 30 22:24:34 2005 GMT
@@ -23,12 +23,19 @@
 #include "xdebug_xml.h"
 #include "xdebug_compat.h"
 
+extern char* xmlize(char *string, int len, int *newlen);
+
 static void xdebug_xml_return_attribute(xdebug_xml_attribute* attr, xdebug_str* output)
 {
+ char *tmp;
+ int newlen;
+
         xdebug_str_addl(output, " ", 1, 0);
         xdebug_str_add(output, attr->name, 0);
         xdebug_str_addl(output, "=\"", 2, 0);
- xdebug_str_add(output, attr->value, 0);
+ tmp = xmlize(attr->value, strlen(attr->value), &newlen);
+ xdebug_str_add(output, tmp, 0);
+ efree(tmp);
         xdebug_str_addl(output, "\"", 1, 0);
         
         if (attr->next) {

[FILE: /xdebug/xdebug_var.c]

===================================================================
RCS file: cvstemp,v
retrieving revision 1.55
retrieving revision 1.56
diff -u -r1.55 -r1.56
--- xdebug/xdebug_var.c:1.55 Sat Dec 04 20:45:46 2004 GMT
+++ xdebug/xdebug_var.c Sun Jan 30 22:24:34 2005 GMT
@@ -131,7 +131,10 @@
         if (hash_key->nKeyLength==0) { /* numeric key */
                 xdebug_str_add(str, xdebug_sprintf("%ld => ", hash_key->h), 1);
         } else { /* string key */
- xdebug_str_add(str, xdebug_sprintf("'%s' => ", hash_key->arKey), 1);
+ int newlen = 0;
+ char *tmp2 = php_str_to_str(hash_key->arKey, strlen(hash_key->arKey), "'", 1, "\\'", 2, &newlen);
+ xdebug_str_add(str, xdebug_sprintf("'%s' => ", tmp2), 1);
+ efree(tmp2);
         }
         xdebug_var_export(zv, str, level + 2, debug_zval TSRMLS_CC);
         xdebug_str_addl(str, ", ", 2, 0);
@@ -726,6 +729,12 @@
                 tmp = php_str_to_str(tmp2, len, "<", 1, "&lt;", 4, &len);
                 efree(tmp2);
 
+ tmp2 = php_str_to_str(tmp, len, "\"", 1, "&quot;", 6, &len);
+ efree(tmp);
+
+ tmp = php_str_to_str(tmp2, len, "'", 1, "&apos;", 6, &len);
+ efree(tmp2);
+
                 tmp2 = php_str_to_str(tmp, len, "\n", 1, "&#10;", 5, newlen);
                 efree(tmp);
                 return tmp2;
Received on Mon Jan 31 2005 - 00:24:39 GMT

This archive was generated by hypermail 2.2.0 : Sun Jun 24 2018 - 04:00:03 BST