Fix bug 708515, whereby file:// URLs would not count as real references for raster image embedding.
This commit is contained in:
parent
a99b7e27ea
commit
04d72454c5
1 changed files with 12 additions and 12 deletions
22
scour.py
22
scour.py
|
|
@ -2390,24 +2390,24 @@ def embedRasters(element, options) :
|
||||||
# look for 'png', 'jpg', and 'gif' extensions
|
# look for 'png', 'jpg', and 'gif' extensions
|
||||||
if ext == 'png' or ext == 'jpg' or ext == 'gif':
|
if ext == 'png' or ext == 'jpg' or ext == 'gif':
|
||||||
|
|
||||||
# check if href resolves to an existing file
|
# file:// URLs denote files on the local system too
|
||||||
if os.path.isfile(href) == False :
|
if href[:7] == 'file://':
|
||||||
if href[:7] != 'http://' and os.path.isfile(href) == False :
|
href = href[7:]
|
||||||
# if this is not an absolute path, set path relative
|
# does the file exist?
|
||||||
# to script file based on input arg
|
if os.path.isfile(href):
|
||||||
infilename = '.'
|
# if this is not an absolute path, set path relative
|
||||||
if options.infilename: infilename = options.infilename
|
# to script file based on input arg
|
||||||
href = os.path.join(os.path.dirname(infilename), href)
|
infilename = '.'
|
||||||
|
if options.infilename: infilename = options.infilename
|
||||||
|
href = os.path.join(os.path.dirname(infilename), href)
|
||||||
|
|
||||||
rasterdata = ''
|
rasterdata = ''
|
||||||
# test if file exists locally
|
# test if file exists locally
|
||||||
if os.path.isfile(href) == True :
|
if os.path.isfile(href):
|
||||||
# open raster file as raw binary
|
# open raster file as raw binary
|
||||||
raster = open( href, "rb")
|
raster = open( href, "rb")
|
||||||
rasterdata = raster.read()
|
rasterdata = raster.read()
|
||||||
|
|
||||||
elif href[:7] == 'http://':
|
elif href[:7] == 'http://':
|
||||||
# raster = open( href, "rb")
|
|
||||||
webFile = urllib.urlopen( href )
|
webFile = urllib.urlopen( href )
|
||||||
rasterdata = webFile.read()
|
rasterdata = webFile.read()
|
||||||
webFile.close()
|
webFile.close()
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue