Config: Properly prevent keys getting transformed into bools

The original regex almost completely failed at its objective, because it a) only worked if there was no value for the key, and b) did not prevent all such occurrences getting transformed, while quoting patterns that would not get transformed anyway.
This commit is contained in:
Dylan K. Taylor
2018-08-18 16:35:39 +01:00
parent b4694092b7
commit 3892f2f404
2 changed files with 72 additions and 1 deletions

View File

@ -111,7 +111,7 @@ class Config{
* @return string
*/
public static function fixYAMLIndexes(string $str) : string{
return preg_replace("#^([ ]*)([a-zA-Z_]{1}[ ]*)\\:$#m", "$1\"$2\":", $str);
return preg_replace("#^( *)(y|Y|yes|Yes|YES|n|N|no|No|NO|true|True|TRUE|false|False|FALSE|on|On|ON|off|Off|OFF)( *)\:#m", "$1\"$2\"$3:", $str);
}
/**