#At file:///Users/jimw/my/mysql-5.0--bug27884/ based on revid:alexey.kopytov@stripped
2850 Jim Winstead 2009-11-23
Backport fix for Bug #27884.
modified:
client/mysql.cc
mysql-test/r/mysql.result
mysql-test/t/mysql.test
=== modified file 'client/mysql.cc'
--- a/client/mysql.cc 2009-10-20 04:42:10 +0000
+++ b/client/mysql.cc 2009-11-23 22:38:08 +0000
@@ -3387,9 +3387,12 @@ print_table_data_html(MYSQL_RES *result)
{
while((field = mysql_fetch_field(result)))
{
- tee_fprintf(PAGER, "<TH>%s</TH>", (field->name ?
- (field->name[0] ? field->name :
- " ") : "NULL"));
+ tee_fputs("<TH>", PAGER);
+ if (field->name && field->name[0])
+ xmlencode_print(field->name, field->name_length);
+ else
+ tee_fputs(field->name ? " " : "NULL", PAGER);
+ tee_fputs("</TH>", PAGER);
}
(void) tee_fputs("</TR>", PAGER);
}
@@ -3400,7 +3403,7 @@ print_table_data_html(MYSQL_RES *result)
for (uint i=0; i < mysql_num_fields(result); i++)
{
(void) tee_fputs("<TD>", PAGER);
- safe_put_field(cur[i],lengths[i]);
+ xmlencode_print(cur[i], lengths[i]);
(void) tee_fputs("</TD>", PAGER);
}
(void) tee_fputs("</TR>", PAGER);
=== modified file 'mysql-test/r/mysql.result'
--- a/mysql-test/r/mysql.result 2009-06-15 15:29:26 +0000
+++ b/mysql-test/r/mysql.result 2009-11-23 22:38:08 +0000
@@ -199,4 +199,5 @@ COUNT (*)
COUNT (*)
1
ERROR 2005 (HY000) at line 1: Unknown MySQL server host 'invalid_hostname' (errno)
+<TABLE BORDER=1><TR><TH><</TH></TR><TR><TD>< & ></TD></TR></TABLE>
End of 5.0 tests
=== modified file 'mysql-test/t/mysql.test'
--- a/mysql-test/t/mysql.test 2009-06-15 15:29:26 +0000
+++ b/mysql-test/t/mysql.test 2009-11-23 22:38:08 +0000
@@ -356,4 +356,10 @@ remove_file $MYSQLTEST_VARDIR/tmp/bug310
--exec $MYSQL --default-character-set=binary test -e "CONNECT test invalid_hostname" 2>&1
--exec $MYSQL --default-character-set=binary test -e "DELIMITER //" 2>&1
+#
+# Bug #27884: mysql --html does not quote HTML special characters in output
+#
+--exec $MYSQL --html test -e "select '< & >' as \`<\`"
+--echo
+
--echo End of 5.0 tests
Attachment: [text/bzr-bundle] bzr/jimw@mysql.com-20091123223808-43h3rjewtsbb5612.bundle
| Thread |
|---|
| • bzr commit into mysql-5.0-bugteam branch (jimw:2850) Bug#27884 | Jim Winstead | 23 Nov |