You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
// The key 'RECAPTCHA_LANG' must match the list provided by Google, or be left empty
380
-
// If any other key is used, we will show an error
381
-
if (array_key_exists('RECAPTCHA_LANG', $validate) && !in_array($validate['RECAPTCHA_LANG'], $this->reCaptchaLanguages))
382
-
{
383
-
// The supplied value doesn't match the allowed values
384
-
$this->output->addMessage(Output::ERROR, 'reCaptcha must match a language/country code on https://developers.google.com/recaptcha/docs/language - if no code exists for your language you can use "en" or leave the string empty', $originFile, 'RECAPTCHA_LANG');
385
-
}
386
405
}
387
406
388
407
/**
389
-
* Validates a email .txt file
408
+
* Validates an email .txt file
390
409
*
391
410
* Emails must have a subject when the source file has one, otherwise must not have one.
392
411
* Emails must have a signature when the source file has one, otherwise must not have one.
@@ -521,26 +540,129 @@ public function validateIndexFile($originFile)
521
540
}
522
541
523
542
/**
524
-
* Validates the iso.txt file
543
+
* Validates the composer.json file
525
544
*
526
-
* Should only contain 3 lines:
527
-
* 1. English name of the language
528
-
* 2. Native name of the language
529
-
* 3. Line with information about the author
545
+
* Should be valid and contain the necessary information:
if (!$jsonContent['name'] == (substr($originFile, 21) === 'phpbb/phpbb-language-'))
564
+
{
565
+
$this->output->addMessage(Output::FATAL, 'File must have name value which starts with phpbb/phpbb-language- following by the language iso code', $originFile);
566
+
}
567
+
568
+
if (!array_key_exists('description', $jsonContent))
569
+
{
570
+
$this->output->addMessage(Output::FATAL, 'File must contain a description value', $originFile);
571
+
}
572
+
// Check if the type is correctly defined
573
+
if (!$jsonContent['type'] == 'phpbb-language')
574
+
{
575
+
$this->output->addMessage(Output::FATAL, 'File must contain a type with the value "phpbb-language"', $originFile);
576
+
}
577
+
// Check if there is a valid version definition
578
+
if (!array_key_exists('version', $jsonContent))
579
+
{
580
+
$this->output->addMessage(Output::FATAL, 'Language pack needs a version definition.', $originFile);
581
+
}
582
+
elseif ($jsonContent['version'] == '')
583
+
{
584
+
$this->output->addMessage(Output::FATAL, 'The defined version should not be empty.', $originFile);
$this->output->addMessage(Output::FATAL, 'The defined version is in the wrong format.', $originFile);
589
+
}
590
+
// Homepage should be at least an empty string
591
+
if (!array_key_exists('homepage', $jsonContent))
592
+
{
593
+
$this->output->addMessage(Output::FATAL, 'The homepage value is missing, can be an empty string.', $originFile);
594
+
}
595
+
// Check for the correct license value
596
+
if (!$jsonContent['license'] == 'GPL-2.0')
597
+
{
598
+
$this->output->addMessage(Output::FATAL, 'The license value has to be "GPL-2.0"', $originFile);
599
+
}
600
+
// Check for the authors
601
+
if (!array_key_exists('authors', $jsonContent))
602
+
{
603
+
$this->output->addMessage(Output::FATAL, 'The authors value is missing.', $originFile);
604
+
}
605
+
// Check for support, authors should at least give one contact option!
606
+
if (!array_key_exists('support', $jsonContent))
607
+
{
608
+
$this->output->addMessage(Output::FATAL, 'The support value is missing.', $originFile);
609
+
}
610
+
elseif (count ($jsonContent['support']) < 1)
611
+
{
612
+
$this->output->addMessage(Output::FATAL, 'The support value has not sub values. Please provide at least one contact option e.g. forum, email.', $originFile);
613
+
}
614
+
// Check for the extra-section
615
+
if (!array_key_exists('extra', $jsonContent))
616
+
{
617
+
$this->output->addMessage(Output::FATAL, 'The extra section is missing.', $originFile);
618
+
}
619
+
// language-iso must be valid
620
+
if (preg_match('^(?:[a-z]*_?){0,2}[a-z]*$', $jsonContent['extra']['language-iso']))
621
+
{
622
+
$this->output->addMessage(Output::FATAL, 'The language-iso should only contain small letters from a to z or maximum two underscores.', $originFile);
623
+
}
624
+
// Check for english name
625
+
if ($jsonContent['extra']['english-name'] == '' || preg_match('^[a-zA-Z\s]+$', $jsonContent['extra']['english-name']))
626
+
{
627
+
$this->output->addMessage(Output::ERROR, 'The english-name value should only contain letters aA-zZ and spaces.', $originFile);
628
+
}
629
+
// Check for local name
630
+
if ($jsonContent['extra']['local-name'] == '')
631
+
{
632
+
$this->output->addMessage(Output::ERROR, 'The local-name value should not be empty.', $originFile);
633
+
}
634
+
// Check for valid phpBB-Version, we accept: 4.0.0, 4.0.0-a1 or 4.0.0-b1 or 4.0.0-RC1
635
+
if (!preg_match('^\d+\.\d+\.\d+(-(?:a|b|RC)\d+)?$', $jsonContent['extra']['phpbb-version']) || $jsonContent['extra']['phpbb-version'] == '' )
636
+
{
637
+
$this->output->addMessage(Output::FATAL, 'The phpbb-version value should not be empty and contain a valid version number.', $originFile);
$this->output->addMessage(Output::FATAL, 'The direction can only be rtl or ltr.', $originFile);
644
+
}
645
+
// Check for user-lang: en-gb
646
+
if (!isset($jsonContent['extra']['user-lang']) || $jsonContent['extra']['user-lang'] == '')
647
+
{
648
+
$this->output->addMessage(Output::FATAL, 'The user-lang must be defined.', $originFile);
649
+
}
650
+
// Check for plural-rule
651
+
if (!preg_match('^(?:[0-9]|1[0-5])$', $jsonContent['extra']['plural-rule']))
652
+
{
653
+
$this->output->addMessage(Output::FATAL, 'Plural rules does not have a valid value.', $originFile);
654
+
}
655
+
// Check for valid recaptcha-lang: en-GB
656
+
if (!in_array($jsonContent['extra']['recaptcha-lang'], $this->reCaptchaLanguages))
657
+
{
658
+
$this->output->addMessage(Output::ERROR, 'reCaptcha must match a language/country code on https://developers.google.com/recaptcha/docs/language - if no code exists for your language you can use "en" or leave the string empty', $originFile);
659
+
}
660
+
// Check for valid turnstile-lang: en (should be in: https://developers.cloudflare.com/turnstile/reference/supported-languages/ )
661
+
if (!in_array($jsonContent['extra']['turnstile-lang'], $this->reTurnstilesLanguages))
662
+
{
663
+
$this->output->addMessage(Output::ERROR, 'Turnstile must match a 2-digit-language code from https://developers.cloudflare.com/turnstile/reference/supported-languages/ ', $originFile);
664
+
}
665
+
}
544
666
545
667
/**
546
668
* Validates whether a file checks for the IN_PHPBB constant
0 commit comments