[FTL] Selectors containing quotes result in `expected literal` error

RESOLVED FIXED

Status

defect
P3
normal
RESOLVED FIXED
2 months ago
2 months ago

People

(Reporter: jk, Assigned: mathjazz)

Tracking

Trunk
Points:
---

Firefox Tracking Flags

(Not tracked)

Details

Attachments

(1 attachment)

User Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/75.0.3770.100 Safari/537.36

Steps to reproduce:

Attempt to translate the following Fluent string in the "classic" Pontoon interface (not Translate.Next).

identifier = { NUMBER($var, type:  "ordinal")->
  [1] first
  [one] { $var }st
 *[other] { $var }nd
}

Actual results:

When attempting to submit a translation, an expected literal error appears.

View the translation as using the raw FTL viewer and the missing literal is the "ordinal" term:

identifier = { NUMBER($var, type:  ->
  [1] first
  [one] { $var }st
 *[other] { $var }nd
}

Expected results:

The translation should be possible to save with no expected literal error and the Fluent string should retain the all the syntax of the source string.

While Pontoon doesn't show selectors (e.g. NUMBER($var, type: "ordinal")) in the rich UI, it still stores them in DOM to help with serialization.

Specifically, it naïvely puts them in data- attributes. Without any escaping, so when selector contains quotes, content gets stripped.

Assignee: nobody → m
Status: UNCONFIRMED → NEW
Ever confirmed: true
Priority: -- → P3
Summary: Fluent parsing causes `expected literal` check to fail on some strings in Pontoon → [FTL] Selectors containing quotes result in `expected literal` error

Thanks for fixing so quickly! We were going to submit a PR for this, but you beat us to it! :)

Thanks for reporting! I'd appreciate a code review in https://github.com/mozilla/pontoon/pull/1334.

Commented on the PR: My colleague @elisehein would be best placed to do a review.

Status: NEW → RESOLVED
Closed: 2 months ago
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.