Mercurial > octave
changeset 23240:e3cb3b761aa7
Only imread a URL if the input looks like a URL (bug #49228).
* imageIO.m: Add regexp test to identify URL before attempting urlwrite.
author | Rik <rik@octave.org> |
---|---|
date | Sun, 26 Feb 2017 15:32:57 -0800 |
parents | 6c691829a24d |
children | 756c7a550542 |
files | scripts/image/private/imageIO.m |
diffstat | 1 files changed, 8 insertions(+), 7 deletions(-) [+] |
line wrap: on
line diff
--- a/scripts/image/private/imageIO.m Sun Feb 26 20:29:19 2017 +0100 +++ b/scripts/image/private/imageIO.m Sun Feb 26 15:32:57 2017 -0800 @@ -54,22 +54,23 @@ ## Filename was given with file extension fn = abs_path (filename); if (isempty (fn) && ! isempty (varargin)) - ## Maybe if we add a file extension + ## Maybe if we add a file extension? fn = abs_path ([filename "." varargin{1}]); endif - ## Maybe we have an URL - if (isempty (fn)) + ## Maybe we have a URL + if (isempty (fn) + && ! isempty (regexp (filename, '^[a-zA-Z][a-zA-Z0-9.+-]+:'))) file_2_delete = true; # mark file for deletion [fn, ~] = urlwrite (filename, tempname ()); - ## Maybe the URL is missing the file extension + ## Maybe the URL is missing the file extension? if (isempty (fn) && ! isempty (varargin)) [fn, ~] = urlwrite ([filename "." varargin{1}], tempname ()); endif + endif - if (isempty (fn)) - error ("%s: unable to find file %s", func, filename); - endif + if (isempty (fn)) + error ([func ": unable to find file " filename]); endif ## unwind_protect block because we may have a file to remove in the end