Skip to content

Commit

Permalink
Merge pull request #972 from flodolo/ftl_accesskeys
Browse files Browse the repository at this point in the history
Ignore message references in FTL accesskeys
  • Loading branch information
flodolo authored Jul 29, 2019
2 parents 33d0ceb + b0758b5 commit e9e1908
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions app/models/accesskeys.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,21 @@ function ($entity) {
];

$ak_results = [];
$ftl_identifier_pattern = '/\s*\{\s*[a-zA-Z\-.]*\s*\}/u';
foreach ($ak_string_ids as $ak_string_id) {
// Exclude accesskey if it's in a FTL file and includes PLATFORM()
if (strpos($ak_string_id, '.ftl:') !== false && strpos($source[$ak_string_id], 'PLATFORM()') !== false) {
continue;
// Exclude edge cases for FTL files
if (mb_strpos($ak_string_id, '.ftl:') !== false) {
// Exclude accesskey if it includes PLATFORM()
if (mb_strpos($source[$ak_string_id], 'PLATFORM()') !== false) {
continue;
}

// Exclude accesskey if it's a reference to another message
$matches = [];
preg_match_all($ftl_identifier_pattern, $source[$ak_string_id], $matches);
if (count($matches[0]) > 0) {
continue;
}
}

if (isset($known_mappings[$ak_string_id])) {
Expand Down

0 comments on commit e9e1908

Please sign in to comment.