Menu

#34 Problem with output of the expected or actual string having %

v1.0.0beta4
closed-accepted
nobody
None
5
2014-12-28
2014-12-09
No

There is a bug in printing out failures for string asserts/expectations, if the expected or actual string has '%', because it is later on used in call to vprintf(), which will interpret it as a format specifier.

I found it while testing some URL encoding - expected string was "i%22zec" (URL encoded "i\"zec"), but the output was something like: "i 2352356163ec". The "nice" thing is that you won't see it if test passes, as the problem is not in the comparison, but just in the reporting of failed comparison.

The attached patch is maybe not the smartest thing to do, but it works - I added doubling of '%' to "%%" in the string to be returned from failure_message_for() in message_formatting.c.

1 Attachments

Discussion

  • Thomas Nilefalk

    Thomas Nilefalk - 2014-12-28

    Thanks for that report. A fix based on your patch is included in revision 561.

     
  • Thomas Nilefalk

    Thomas Nilefalk - 2014-12-28
    • status: open --> closed-accepted
    • Group: Unknown --> v1.0.0beta4
     

Log in to post a comment.

MongoDB Logo MongoDB