-
Notifications
You must be signed in to change notification settings - Fork 703
Description
Help us to keep this issue-tracker clean! For questions or support, please refer to our mailing lists
Specifics of your environment
- Are you acting as SP/IdP/proxy? IdP
- SimpleSAMLphp: What version are you using? 2.3.7
- PHP: What version are you using? 8.2
- Platform: unix or Windows? unix
- Webserver: Apache/Nginx/ISS? Nginx
Describe the bug
Tags in translation filters used in twig template aren't beeing replaced.
This is noticeable in the consent module where translations that have variables for the translation filter in the twig template aren't being replaced.
Example in the EN version the %SPNAME% is replaced by the correct one, in the PT version this tag is not replaced and remains %SPNAME%.
Any language that is the EN should work to trigger the bug.
To Reproduce
Steps to reproduce the behavior:
Requires to have a IdP multi-languages enabled and the conset module
(In reality there should be other ways to trigger this)
- Login normally
- In the consent form, change language to any other then EN, if not already
- See the tags %SPNAME%
Expected behavior
The expected behavior is the tags to be replaced in other languages other the EN.
Additional context
This bug, was probably introduced with the reworks done in the function translateSingularGettext in
[/src/SimpleSAML/Locale/Translate.php], reworks done after versions 2.2.2.
But weren't that noticeable before, but now with the default domain beeing added it not set, is noticeable.
Resolution or findings
What i found debugging the matter.
I found that in the file simplesamlphp-2.3.7/src/SimpleSAML/Locale/Localization.php line 268, a domain is added if empty, after loading the the Po file.
But this changes the interactions in translateSingularGettext in the file simplesamlphp-2.3.7/src/SimpleSAML/Locale/Translate.php line 77
This change trigger the condition in the foreach line 88, and returns, this prevents the $text to reach the part of the code where if would be processed and the tags replaced (like %SPNAME%)
I propose that the return, is changed to a break, to allow the rest of the processing to done.
Diff bellow
--- simplesamlphp-2.3.7/src/SimpleSAML/Locale/Translate.php
+++ simplesamlphp-2.3.7-vmendonca-changed/src/SimpleSAML/Locale/Translate.php
@@ -88,7 +88,7 @@
foreach (self::$defaultDomains as $d) {
$text = TranslatorFunctions::getTranslator()->dgettext($d, $original);
if ($text != $original) {
- return $text;
+ break;
}
}
Additionally this is not trigger in the EN version, because in the locate of the EN versions the msgid and the msgstr are the same, this avoids the return.