pontoon icon indicating copy to clipboard operation
pontoon copied to clipboard

Broken UI and errors in Fluent string with empty attribute

Open flodolo opened this issue 3 years ago • 4 comments

Here's the string https://pontoon.mozilla.org/hye/firefox/browser/browser/places.ftl/?search=places-open-in-container-tab&string=243435

My checks were triggered, because Pontoon committed a non parseable entity to hg

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

I'm not sure how the localizer got there, but now Pontoon breaks in all possible ways:

  • Switching to FTL mode, then back, will hide the input fields.
  • Trying to reject or approve the translation will result in a blank page.

flodolo avatar Apr 06 '22 19:04 flodolo

Looks like there's a tab character in the accesskey value, which allowed the user to submit a broken string in first place.

mathjazz avatar Apr 15 '22 15:04 mathjazz

So the string contains a tab character, but it gets removed when we serialize the string to send it to VCS or show it in the FTL source editor.

@eemeli Does that look like a bug in python-fluent? If tab character is valid in the value, why do we drop it on re-serialization?

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'

mathjazz avatar Apr 23 '22 10:04 mathjazz

Yes, that looks like a python-fluent bug. According to the spec, only spaces are included in blank_inline, and effectively tabs should be considered here as inline_text, i.e. a part of the message's value.

eemeli avatar Apr 23 '22 12:04 eemeli

The syntax js parser in the playground also doesn't show the tab as part of the TextElement.

Pike avatar Apr 23 '22 15:04 Pike

Seems like recent updates to the editor have fixed the Pontoon side of the issue. 👍

@eemeli Do we track the python-fluent part somewhere?

mathjazz avatar Feb 28 '23 23:02 mathjazz

@mathjazz This has been fixed in python-fluent, but hasn't yet been included in a release of it. That's currently blocked by waiting for projectfluent/python-fluent#180 to land. If you feel like reviewing that we could get this forward... 😇

eemeli avatar Mar 01 '23 07:03 eemeli