projectfluent / python-fluent

Python implementation of Project Fluent
https://projectfluent.org/python-fluent/
Other
210 stars 26 forks source link

Incorrect handling of tabs in message value #173

Closed eemeli closed 1 year ago

eemeli commented 2 years ago

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.

Pike commented 2 years ago

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

eemeli commented 2 years ago

Yeah, will need to check all the implementations.