diff --git a/translate/storage/placeables/general.py b/translate/storage/placeables/general.py index 22db81c688..ac1b1b176d 100644 --- a/translate/storage/placeables/general.py +++ b/translate/storage/placeables/general.py @@ -157,7 +157,7 @@ class FormattingPlaceable(Ph): regex = re.compile(r""" % # introduction (\d+\$)? # selection of non-next variable (reordering) - [\-\+0 \#'I]? # optional flag + [\-\+0\#'I]? # optional flag ((\d+)|[*])? # field width (\.\d+)? # precision [hlI]? # length diff --git a/translate/storage/placeables/test_general.py b/translate/storage/placeables/test_general.py index 7f7de16f6b..0cde2a1136 100644 --- a/translate/storage/placeables/test_general.py +++ b/translate/storage/placeables/test_general.py @@ -102,7 +102,10 @@ def test_placeable_formatting(): assert fp.parse(u'There were %d %s')[3] == fp([u'%s']) assert fp.parse(u'%1$s was kicked by %2$s')[0] == fp([u'%1$s']) assert fp.parse(u'There were %Id cows')[1] == fp([u'%Id']) - assert fp.parse(u'There were % d cows')[1] == fp([u'% d']) + + # Skip placeholders with whitespace. + assert fp.parse(u'There were % d cows') is None + # only a real space is allowed as formatting flag assert fp.parse(u'There were %\u00a0d cows') is None assert fp.parse(u"There were %'f cows")[1] == fp([u"%'f"])