#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:


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>


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 12 months ago by Even Rouault

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

comment:2 Changed 12 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 12 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.