]> git.immae.eu Git - github/shaarli/Shaarli.git/commitdiff
Replaced PHP_EOL to "\n"
authorGanesh Kandu <kanduganesh@gmail.com>
Tue, 27 Oct 2020 12:12:35 +0000 (17:42 +0530)
committerGitHub <noreply@github.com>
Tue, 27 Oct 2020 12:12:35 +0000 (17:42 +0530)
i was getting error

```
An error occurred while parsing JSON configuration file (data/config.json.php): error code #4
➜ Syntax error
Please check your JSON syntax (without PHP comment tags) using a JSON lint tool such as jsonlint.com.
```
after debug i found
```php
        $data = str_replace(self::getPhpHeaders(), '', $data);
        $data = str_replace(self::getPhpSuffix(), '', $data);
```
doesn't removing php header and php suffix

cause of this issue was PHP_EOL represents the endline character for the current system. if my  ```config.json.php```  was encoded with unix ( LF ) and php running on windows windows encoding ( CR LF ) is not same as unix encoding ( LF ) so ```str_replace``` doesn't replace strin  then it causes issue.

application/config/ConfigJson.php

index c0c0dab9ab9df4ce10f0a8217ae28a88dc011483..eaa4ee3f87d153815dac5da07d18d3068f4c34b5 100644 (file)
@@ -73,7 +73,7 @@ class ConfigJson implements ConfigIO
      */
     public static function getPhpHeaders()
     {
-        return '<?php /*'. PHP_EOL;
+        return '<?php /*'. "\n";
     }
 
     /**
@@ -85,6 +85,6 @@ class ConfigJson implements ConfigIO
      */
     public static function getPhpSuffix()
     {
-        return PHP_EOL . '*/ ?>';
+        return "\n" . '*/ ?>';
     }
 }