Skip to content

Commit

Permalink
Fix false positive in FTL variables caused by properties checks (#977)
Browse files Browse the repository at this point in the history
'{ $brandname } installed` was not detected by properties check (correctly), but `{$brandname} installed` was, causing false positives in FTL.

Sadly, it's not possible to use quantifier in negative lookahead.

A structural improvement would be to pass the limit checks to specific file extensions.
  • Loading branch information
flodolo authored Oct 11, 2019
1 parent 4a14006 commit 1e780fd
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
2 changes: 1 addition & 1 deletion app/classes/Transvision/AnalyseStrings.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public static function differences($tmx_source, $tmx_target, $repo, $ignored_str
// %1$S or %S. %1$0.S and %0.S are valid too
'printf' => '/(%(?:[0-9]+\$){0,1}(?:[0-9].){0,1}([sS]))/',
// $BrandShortName, but not "My%1$SFeeds-%2$S.opml" or "{ $brandShortName }"
'properties' => '/(?<!%[0-9]|\{\s)(\$[A-Za-z0-9\.]+)\b/',
'properties' => '/(?<!%[0-9]|\{\s|\{)(\$[A-Za-z0-9\.]+)\b/',
// %1$s or %s. %d
'xml_android' => '/(%(?:[0-9]+\$){0,1}([sd]))/',
];
Expand Down
16 changes: 16 additions & 0 deletions tests/units/Transvision/AnalyseStrings.php
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,22 @@ public function differencesDP()
[],
['browser:foobar16'],
],
[
// Difference spacing in variable for FTL (not an error)
['browser:foobar16a1' => '{ $brandname } installed'],
['browser:foobar16a1' => '{$brandname} installato'],
'gecko_strings',
[],
[],
],
[
// Difference spacing in variable for FTL (not an error)
['browser:foobar16a2' => '{$brandname} installed'],
['browser:foobar16a2' => '{ $brandname } installato'],
'gecko_strings',
[],
[],
],
[
// Missing message reference for FTL
['browser:foobar16b' => '{ other-message } installed'],
Expand Down

0 comments on commit 1e780fd

Please sign in to comment.