diff --git a/client/mysqltest.cc b/client/mysqltest.cc
index 459abf8ffe122781b2163f026719dc7535b23d34..dfd383cc714505e33217a9508b8b311c89646a3e 100644
--- a/client/mysqltest.cc
+++ b/client/mysqltest.cc
@@ -5678,6 +5678,17 @@ void do_block(enum block_cmd cmd, struct st_command* command)
     while (my_isspace(charset_info, *curr_ptr))
       curr_ptr++;
 
+    /* Strip off trailing white space */
+    while (my_isspace(charset_info, expr_end[-1]))
+      expr_end--;
+    /* strip off ' or " around the string */
+    if (*curr_ptr == '\'' || *curr_ptr == '"')
+    {
+      if (expr_end[-1] != *curr_ptr)
+        die("Unterminated string value");
+      curr_ptr++;
+      expr_end--;
+    }
     VAR v2;
     var_init(&v2,0,0,0,0);
     eval_expr(&v2, curr_ptr, &expr_end);
diff --git a/mysql-test/extra/rpl_tests/rpl_implicit_commit_binlog.test b/mysql-test/extra/rpl_tests/rpl_implicit_commit_binlog.test
index bbd4969ef401ae9159369b40f8127123ee77a83a..172483e1466320aa73d999af3f1a91334ed4dfd0 100644
--- a/mysql-test/extra/rpl_tests/rpl_implicit_commit_binlog.test
+++ b/mysql-test/extra/rpl_tests/rpl_implicit_commit_binlog.test
@@ -36,8 +36,8 @@ let $ddl_cases= 41;
 while ($ddl_cases >= 1)
 {
   --echo -b-b-b-b-b-b-b-b-b-b-b- >> << -b-b-b-b-b-b-b-b-b-b-b-
-  let $in_temporary= "no";
-  let $ok= "yes";
+  let $in_temporary= no;
+  let $ok= yes;
   #
   # In SBR and MIXED modes, the commit event is usually the third event in the
   # binary log:
@@ -91,7 +91,7 @@ while ($ddl_cases >= 1)
     {
       # This seems to be related to epochs.
       # We need to check this against an updated version or avoid it.
-      let $ok= "no";
+      let $ok= no;
       let $commit_event_row_number= 6;
     }
   }
@@ -356,7 +356,7 @@ while ($ddl_cases >= 1)
   if ($ddl_cases == 11)
   {
     let $cmd= CREATE TEMPORARY TABLE tt_xx (a int);
-    let $in_temporary= "yes";
+    let $in_temporary= yes;
     # In SBR and MIXED modes, the DDL statement is written to the binary log but
     # does not commit the current transaction.
     #
@@ -478,7 +478,7 @@ while ($ddl_cases >= 1)
   if ($ddl_cases == 8)
   {
     let $cmd= DROP TEMPORARY TABLE IF EXISTS new_tt_xx;
-    let $in_temporary= "yes";
+    let $in_temporary= yes;
     #
     # In SBR and MIXED modes, the DDL statement is written to the binary log
     # but does not commit the current transaction:
@@ -618,14 +618,14 @@ while ($ddl_cases >= 1)
   # commit. The flag in_temporary is used to avoid aborting the test in such
   # cases. Thus we force the commit.
   #
-  if ($in_temporary == "yes")
+  if ($in_temporary == yes)
   {
     --eval COMMIT
   }
   let $event_commit= query_get_value("SHOW BINLOG EVENTS FROM $first_binlog_position", Info, $commit_event_row_number);
   if (`SELECT SUBSTRING("$event_commit",1,6) != "COMMIT"`)
   {
-    if ($ok == "yes")
+    if ($ok == yes)
     {
       --echo it *does not* commit the current transaction.
       --echo $cmd
diff --git a/mysql-test/r/mysqltest.result b/mysql-test/r/mysqltest.result
index f5dce1e41968fa6edeea21da37862491eca935a4..6892164c2259b66c550ee3a8b0a03519fcc5cf40 100644
--- a/mysql-test/r/mysqltest.result
+++ b/mysql-test/r/mysqltest.result
@@ -423,7 +423,10 @@ while with string, only once
 hello == hello
 hello   ==   hello
 hello != goodbye
+'quoted' == ''quoted''
 two words
+'two words'
+"two words"
 two words are two words
 right answer
 anything goes
diff --git a/mysql-test/t/mysqltest.test b/mysql-test/t/mysqltest.test
index cde517be03a151fd970fc21fdff55424a2f725ac..186b0e0fbfad8781a91bb1b47c18a1b1faa05b9b 100644
--- a/mysql-test/t/mysqltest.test
+++ b/mysql-test/t/mysqltest.test
@@ -1276,12 +1276,24 @@ if ($ifvar != goodbye)
 {
   echo hello != goodbye;
 }
-
+let $ifvar= 'quoted';
+if ($ifvar == ''quoted'')
+{
+  echo 'quoted' == ''quoted'';
+}
 let $ifvar= two words;
 if ($ifvar == two words)
 {
   echo two words;
 }
+if ($ifvar == 'two words')
+{
+  echo 'two words';
+}
+if ($ifvar == "two words")
+{
+  echo "two words";
+}
 if ($ifvar == `SELECT 'two words'`)
 {
   echo two words are two words;