Date: Tue Aug 3 00:04:34 CEST 2004
User: Shane Caraveo
Directory: xdebug
Log Message:
[2:00]
- add text node structure to better handle base64 encoding text nodes
- make string values of variables always encoded.
# fixes http://bugs.activestate.com/show_bug.cgi?id=33152
Modified files:
xdebug/xdebug_handler_dbgp.c (version: 1.55)
xdebug/xdebug_var.c (version: 1.48)
xdebug/xdebug_xml.c (version: 1.6)
xdebug/xdebug_xml.h (version: 1.3)
[FILE: /xdebug/xdebug_handler_dbgp.c]
===================================================================
RCS file: cvstemp,v
retrieving revision 1.54
retrieving revision 1.55
diff -u -r1.54 -r1.55
--- xdebug/xdebug_handler_dbgp.c:1.54 Tue Jul 20 14:34:31 2004 GMT
+++ xdebug/xdebug_handler_dbgp.c Mon Aug 02 20:04:34 2004 GMT
@@ -13,6 +13,7 @@
| xdebug[@]derickrethans.nl so we can mail you a copy immediately. |
+----------------------------------------------------------------------+
| Authors: Derick Rethans <derick[@]xdebug.org> |
+ | Shane Caraveo <shanec[@]ActiveState.com> |
+----------------------------------------------------------------------+
*/
@@ -785,18 +786,13 @@
{
/* create an xml document to send as the stream */
xdebug_xml_node *message;
- int new_len;
- char *encoded_source;
message = xdebug_xml_node_init("stream");
xdebug_xml_add_attribute_ex(message, "type", (char *)name, 0, 0);
- xdebug_xml_add_attribute_ex(message, "encoding", "base64", 0, 0);
- encoded_source = xdebug_base64_encode(str, str_length, &new_len);
- xdebug_xml_add_text(message, xdstrdup(encoded_source));
+ xdebug_xml_add_text_encode(message, xdstrdup(str));
send_message(&XG(context), message);
xdebug_xml_node_dtor(message);
- efree(encoded_source);
return 0;
}
@@ -947,16 +943,13 @@
if (CMD_OPTION('e')) {
begin = strtol(CMD_OPTION('e'), NULL, 10);
}
+ /* return_source allocates memory for source */
source = return_source(filename, begin, end TSRMLS_CC);
if (!source) {
RETURN_RESULT(XG(status), XG(reason), XDEBUG_ERROR_CANT_OPEN_FILE);
} else {
- xdebug_xml_add_attribute(*retval, "encoding", "base64");
- encoded_source = xdebug_base64_encode(source, strlen(source), &new_len);
- xdebug_xml_add_text(*retval, xdstrdup(encoded_source));
- efree(encoded_source);
- xdfree(source);
+ xdebug_xml_add_text_encode(*retval, source);
}
}
@@ -1596,7 +1589,7 @@
char *xdebug_dbgp_get_revision(void)
{
- return "$Revision: 1.54 $";
+ return "$Revision: 1.55 $";
}
int xdebug_dbgp_cmdloop(xdebug_con *context TSRMLS_DC)
[FILE: /xdebug/xdebug_var.c]
===================================================================
RCS file: cvstemp,v
retrieving revision 1.47
retrieving revision 1.48
diff -u -r1.47 -r1.48
--- xdebug/xdebug_var.c:1.47 Fri Jul 16 21:20:06 2004 GMT
+++ xdebug/xdebug_var.c Mon Aug 02 20:04:34 2004 GMT
@@ -475,7 +475,7 @@
case IS_STRING:
xdebug_xml_add_attribute(node, "type", "string");
- xdebug_xml_add_text(node, xdstrdup(Z_STRVAL_PP(struc)));
+ xdebug_xml_add_text_encode(node, xdstrdup(Z_STRVAL_PP(struc)));
break;
case IS_ARRAY:
[FILE: /xdebug/xdebug_xml.c]
===================================================================
RCS file: cvstemp,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- xdebug/xdebug_xml.c:1.5 Wed Jun 09 05:07:19 2004 GMT
+++ xdebug/xdebug_xml.c Mon Aug 02 20:04:34 2004 GMT
@@ -36,11 +36,29 @@
}
}
+static void xdebug_xml_return_text_node(xdebug_xml_text_node* node, xdebug_str* output)
+{
+ xdebug_str_addl(output, "<![CDATA[", 9, 0);
+ if (node->encode) {
+ /* if cdata tags are in the text, then we must base64 encode */
+ int new_len = 0;
+ char *encoded_text = xdebug_base64_encode(node->text, strlen(node->text), &new_len);
+ xdebug_str_add(output, encoded_text, 0);
+ efree(encoded_text);
+ } else {
+ xdebug_str_add(output, node->text, 0);
+ }
+ xdebug_str_addl(output, "]]>", 3, 0);
+}
+
void xdebug_xml_return_node(xdebug_xml_node* node, struct xdebug_str *output)
{
xdebug_str_addl(output, "<", 1, 0);
xdebug_str_add(output, node->tag, 0);
+ if (node->text && node->text->encode) {
+ xdebug_xml_add_attribute_ex(node, "encoding", "base64", 0, 0);
+ }
if (node->attribute) {
xdebug_xml_return_attribute(node->attribute, output);
}
@@ -51,16 +69,7 @@
}
if (node->text) {
- if (strstr(node->text, "]]>")) {
- /* if cdata tags are in the text, then we must base64 encode */
- int new_len = 0;
- char *encoded_text = xdebug_base64_encode(node->text, strlen(node->text), &new_len);
- xdebug_str_add(output, encoded_text, 0);
- } else {
- xdebug_str_addl(output, "<![CDATA[", 9, 0);
- xdebug_str_add(output, node->text, 0);
- xdebug_str_addl(output, "]]>", 3, 0);
- }
+ xdebug_xml_return_text_node(node->text, output);
}
xdebug_str_addl(output, "</", 2, 0);
@@ -117,15 +126,27 @@
*ptr = child;
}
-void xdebug_xml_add_text(xdebug_xml_node *xml, char *text)
+static void xdebug_xml_text_node_dtor(xdebug_xml_text_node* node)
{
+ if (node->free_value && node->text) {
+ xdfree(node->text);
+ }
+ xdfree(node);
+}
+
+void xdebug_xml_add_text_ex(xdebug_xml_node *xml, char *text, int free_text, int encode)
+{
+ xdebug_xml_text_node *node = xdmalloc(sizeof (xdebug_xml_text_node));
+ node->free_value = free_text;
+ node->encode = encode;
+
if (xml->text) {
- xdfree(xml->text);
+ xdebug_xml_text_node_dtor(xml->text);
}
- xml->text = text;
- if (strstr(xml->text, "]]>")) {
- /* if cdata tags are in the text, then we must base64 encode */
- xdebug_xml_add_attribute_ex(xml, "encoding", "base64", 0, 0);
+ node->text = text;
+ xml->text = node;
+ if (!encode && strstr(node->text, "]]>")) {
+ node->encode = 1;
}
}
@@ -158,7 +179,7 @@
xdfree(xml->tag);
}
if (xml->text) {
- xdfree(xml->text);
+ xdebug_xml_text_node_dtor(xml->text);
}
xdfree(xml);
}
[FILE: /xdebug/xdebug_xml.h]
===================================================================
RCS file: cvstemp,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- xdebug/xdebug_xml.h:1.2 Tue Oct 14 14:46:47 2003 GMT
+++ xdebug/xdebug_xml.h Mon Aug 02 20:04:34 2004 GMT
@@ -22,6 +22,7 @@
#define __HAVE_XDEBUG_XML_H__
typedef struct _xdebug_xml_attribute xdebug_xml_attribute;
+typedef struct _xdebug_xml_text_node xdebug_xml_text_node;
typedef struct _xdebug_xml_node xdebug_xml_node;
struct _xdebug_xml_attribute
@@ -33,10 +34,18 @@
int free_value;
};
+/* todo: support multiple text nodes inside an element */
+struct _xdebug_xml_text_node
+{
+ char *text;
+ int free_value;
+ int encode;
+};
+
struct _xdebug_xml_node
{
char *tag;
- char *text;
+ struct _xdebug_xml_text_node *text;
struct _xdebug_xml_attribute *attribute;
struct _xdebug_xml_node *child;
struct _xdebug_xml_node *next;
@@ -50,7 +59,10 @@
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_child(xdebug_xml_node *xml, xdebug_xml_node *child);
-void xdebug_xml_add_text(xdebug_xml_node *xml, char *text);
+
+void xdebug_xml_add_text_ex(xdebug_xml_node *xml, char *text, int free_text, int encode);
+#define xdebug_xml_add_text(x,t) xdebug_xml_add_text_ex((x), (t), 1, 0)
+#define xdebug_xml_add_text_encode(x,t) xdebug_xml_add_text_ex((x), (t), 1, 1)
void xdebug_xml_return_node(xdebug_xml_node* node, struct xdebug_str *output);
void xdebug_xml_node_dtor(xdebug_xml_node* xml);
Received on Tue Aug 03 2004 - 00:04:37 BST
This archive was generated by hypermail 2.2.0 : Sun Jun 24 2018 - 04:00:02 BST