Opened 5 months ago

Closed 5 months ago

#7186 closed defect (fixed)

gdal_retile.py fails if the filename contains "%" (percent) symbol.

Reported by: OlegSerov Owned by: warmerdam
Priority: normal Milestone:
Component: default Version: svn-trunk
Severity: normal Keywords:
Cc:

Description

gdal_retile.py fails if the filename contains "%" (percent) symbol..

Error message: `Traceback (most recent call last):

File "/home/ubuntu/.processing_server_env/bin/gdal_retile.py", line 1034, in <module>

sys.exit(main(sys.argv))

File "/home/ubuntu/.processing_server_env/bin/gdal_retile.py", line 940, in main

dsCreatedTileIndex = tileImage(minfo,ti)

File "/home/ubuntu/.processing_server_env/bin/gdal_retile.py", line 355, in tileImage

tilename=getTileName(minfo,ti, xIndex, yIndex)

File "/home/ubuntu/.processing_server_env/bin/gdal_retile.py", line 697, in getTileName

return format % (yIndex,xIndex)

ValueError?: unsupported format character 'N' (0x4e) at index 59`

This happens on this line: https://trac.osgeo.org/gdal/browser/trunk/gdal/swig/python/scripts/gdal_retile.py?rev=28002#L712

Because it uses python formatting to insert x y coordinates. However, it does not escape the original string and the parts of original string tries to be formated.

You should escape all % sign with %%. E.g. a = a.replace('%', '%%')

Attachments (1)

Change History (4)

comment:1 Changed 5 months ago by Even Rouault

Can you attach a patch or a modified version with your suggested fix ?

comment:2 Changed 5 months ago by OlegSerov

I've attached a patch for https://trac.osgeo.org/gdal/browser/branches/2.2/gdal/swig/python/scripts/gdal_retile.py

!!! I have not tested the patch.

comment:3 Changed 5 months ago by Even Rouault

Resolution: fixed
Status: newclosed

In 41134:

gdal_retile.py: fix failure if the filename contains % (percent) symbol (fixes #7186, patch by OlegSerov?)

Note: See TracTickets for help on using tickets.