List:Commits« Previous MessageNext Message »
From:Jim Winstead Date:April 28 2009 5:55pm
Subject:bzr commit into mysql-5.1-bugteam branch (jimw:2875) Bug#27884
View as plain text  
#At file:///Users/jimw/my/mysql-5.1/ based on revid:staale.smedseng@stripped

 2875 Jim Winstead	2009-04-28
      Bug #27884: mysql --html does not quote HTML special characters in output
      
        Fix encoding of field values and names in HTML output from mysql client.
      modified:
        client/mysql.cc
        mysql-test/r/mysql.result
        mysql-test/t/mysql.test

=== modified file 'client/mysql.cc'
--- a/client/mysql.cc	2009-04-14 14:17:44 +0000
+++ b/client/mysql.cc	2009-04-28 17:54:26 +0000
@@ -3381,9 +3381,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 : 
-					  " &nbsp; ") : "NULL"));
+      tee_fputs("<TH>", PAGER);
+      if (field->name && field->name[0])
+        xmlencode_print(field->name, field->name_length);
+      else
+        tee_fputs(field->name ? " &nbsp; " : "NULL", PAGER);
+      tee_fputs("</TH>", PAGER);
     }
     (void) tee_fputs("</TR>", PAGER);
   }
@@ -3396,7 +3399,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-03-24 20:48:31 +0000
+++ b/mysql-test/r/mysql.result	2009-04-28 17:54:26 +0000
@@ -200,4 +200,5 @@ Warning (Code 1286): Unknown table engin
 Warning (Code 1266): Using storage engine MyISAM for table 't2'
 Error (Code 1050): Table 't2' already exists
 drop tables t1, t2;
+<TABLE BORDER=1><TR><TH>&lt;</TH></TR><TR><TD>&lt; &amp; &gt;</TD></TR></TABLE>
 End of tests

=== modified file 'mysql-test/t/mysql.test'
--- a/mysql-test/t/mysql.test	2009-03-24 20:53:25 +0000
+++ b/mysql-test/t/mysql.test	2009-04-28 17:54:26 +0000
@@ -367,4 +367,10 @@ remove_file $MYSQLTEST_VARDIR/tmp/bug310
 
 drop tables t1, t2;
 
+#
+# Bug #27884: mysql --html does not quote HTML special characters in output
+# 
+--exec $MYSQL --html test -e "select '< & >' as \`<\`"
+
+--echo
 --echo End of tests

Thread
bzr commit into mysql-5.1-bugteam branch (jimw:2875) Bug#27884Jim Winstead28 Apr