Merge #14960: lint/format-strings: Correctly exclude escaped percent symbols

57281199b8 lint/format-strings: Correctly exclude escaped percent symbols (Luke Dashjr)

Pull request description:

  The current code fails to exclude correctly for patterns like `"%%%X"`

Tree-SHA512: cac6f6fb3f06a9190310cd9764ec31cd7d636f9c831057622f418ae5fd2e1d80927a88f585d18f57b279ac21e81518f714dc1a25155377b9297741a73600461e
This commit is contained in:
MarcoFalke 2018-12-22 17:13:27 +01:00
commit 18857b4c40
No known key found for this signature in database
GPG key ID: D2EA4850E7528B25

View file

@ -241,12 +241,11 @@ def count_format_specifiers(format_string):
4
"""
assert(type(format_string) is str)
format_string = format_string.replace('%%', 'X')
n = 0
in_specifier = False
for i, char in enumerate(format_string):
if format_string[i - 1:i + 1] == "%%" or format_string[i:i + 2] == "%%":
pass
elif char == "%":
if char == "%":
in_specifier = True
n += 1
elif char in "aAcdeEfFgGinopsuxX":