python-fluent icon indicating copy to clipboard operation
python-fluent copied to clipboard

Incorrect handling of tabs in message value

Open eemeli opened this issue 3 years ago • 2 comments

As identified in https://github.com/mozilla/pontoon/issues/2470#issuecomment-1107451952, this happens:

from fluent.syntax import ast, FluentParser, FluentSerializer
parser = FluentParser()
serializer = FluentSerializer()

string = """places-open-in-container-tab =
    .label = Բացել նոր ներդիրում
    .accesskey =	
"""

string
'places-open-in-container-tab =\n    .label = Բացել նոր ներդիրում\n    .accesskey = \t\n'

serializer.serialize(parser.parse(string))
'places-open-in-container-tab =\n    .label = Բացել նոր ներդիրում\n    .accesskey = \n'

Tabs should not be lost; they count as valid inline_text characters according to the spec.

eemeli avatar Apr 23 '22 12:04 eemeli

Probably also a bug in js syntax parser, and the runtime parser.

Pike avatar Apr 23 '22 15:04 Pike

Yeah, will need to check all the implementations.

eemeli avatar Apr 23 '22 16:04 eemeli