diff options
author | Phil Davis <phil.davis@inf.org> | 2015-07-27 23:36:03 +0545 |
---|---|---|
committer | Phil Davis <phil.davis@inf.org> | 2015-07-27 23:36:03 +0545 |
commit | 2b869fa154626160a4ef4105199d83485831d9ec (patch) | |
tree | d61d8a66ae3986850e45202b52f29eb1d2552f5a | |
parent | 8e24ffdd7a0cea3580f15317275128c6abe924d2 (diff) | |
download | pfsense-2b869fa154626160a4ef4105199d83485831d9ec.zip pfsense-2b869fa154626160a4ef4105199d83485831d9ec.tar.gz |
Strip any \r when parsing URL table ports file
If the URL table ports file at the URL specified has lines separated by "\r\n" rather than just "\n", then the code here ends up with ports that look like "80\r" "443\r" ... and group_ports() does not match any of those and the final file ends up empty. That seems a shame just because the file was made in some editor that put "\r\n" line breaks. I messed about for a while trying to make my URL table ports alias work until I realized this.
This change first strips out any "\r" from the string, thus making it work with files that have either pure "\n" line breaks or "\r\n" line breaks.
-rw-r--r-- | etc/inc/pfsense-utils.inc | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/etc/inc/pfsense-utils.inc b/etc/inc/pfsense-utils.inc index b3215a5..22b0be0 100644 --- a/etc/inc/pfsense-utils.inc +++ b/etc/inc/pfsense-utils.inc @@ -2307,7 +2307,7 @@ function process_alias_urltable($name, $url, $freq, $forceupdate=false) { if (download_file($url, $urltable_filename . ".tmp", $verify_ssl)) { mwexec("/usr/bin/sed -E 's/\;.*//g; /^[[:space:]]*($|#)/d' ". escapeshellarg($urltable_filename . ".tmp") . " > " . escapeshellarg($urltable_filename)); if (alias_get_type($name) == "urltable_ports") { - $ports = explode("\n", file_get_contents($urltable_filename)); + $ports = explode("\n", str_replace("\r", "", file_get_contents($urltable_filename))); $ports = group_ports($ports); file_put_contents($urltable_filename, implode("\n", $ports)); } |