diff options
| -rw-r--r-- | src/sp_config.c | 6 | ||||
| -rw-r--r-- | src/tests/config/windows_eol.ini | 2 | ||||
| -rw-r--r-- | src/tests/windows_eol.phpt | 10 |
3 files changed, 17 insertions, 1 deletions
diff --git a/src/sp_config.c b/src/sp_config.c index aeadd9d..4d95062 100644 --- a/src/sp_config.c +++ b/src/sp_config.c | |||
| @@ -175,7 +175,11 @@ int sp_parse_config(const char *conf_file) { | |||
| 175 | while (getline(&lineptr, &n, fd) > 0) { | 175 | while (getline(&lineptr, &n, fd) > 0) { |
| 176 | /* We trash the terminal `\n`. This simplify the display of logs. */ | 176 | /* We trash the terminal `\n`. This simplify the display of logs. */ |
| 177 | if (lineptr[strlen(lineptr) - 1] == '\n') { | 177 | if (lineptr[strlen(lineptr) - 1] == '\n') { |
| 178 | lineptr[strlen(lineptr) - 1] = '\0'; | 178 | if (lineptr[strlen(lineptr) - 2] == '\r') { |
| 179 | lineptr[strlen(lineptr) - 2] = '\0'; | ||
| 180 | } else { | ||
| 181 | lineptr[strlen(lineptr) - 1] = '\0'; | ||
| 182 | } | ||
| 179 | } | 183 | } |
| 180 | if (parse_line(lineptr) == -1) { | 184 | if (parse_line(lineptr) == -1) { |
| 181 | fclose(fd); | 185 | fclose(fd); |
diff --git a/src/tests/config/windows_eol.ini b/src/tests/config/windows_eol.ini new file mode 100644 index 0000000..eea230c --- /dev/null +++ b/src/tests/config/windows_eol.ini | |||
| @@ -0,0 +1,2 @@ | |||
| 1 | sp.disable_function.function("assert").filename("/tst.php").hash("0df5e049bf954da7054273bd66a3c63e7cbc22fea31bb448c6229f92f04af2b3").allow(); | ||
| 2 | |||
diff --git a/src/tests/windows_eol.phpt b/src/tests/windows_eol.phpt new file mode 100644 index 0000000..0e81274 --- /dev/null +++ b/src/tests/windows_eol.phpt | |||
| @@ -0,0 +1,10 @@ | |||
| 1 | --TEST-- | ||
| 2 | Windows EOL in configuration file | ||
| 3 | --SKIPIF-- | ||
| 4 | <?php if (!extension_loaded("snuffleupagus")) print "skip"; ?> | ||
| 5 | --INI-- | ||
| 6 | sp.configuration_file={PWD}/config/windows_eol.ini | ||
| 7 | --FILE-- | ||
| 8 | <?php echo "1\n"; ?> | ||
| 9 | --EXPECT-- | ||
| 10 | 1 | ||
