aboutsummaryrefslogtreecommitdiffstats
path: root/wkhtmltopdf
diff options
context:
space:
mode:
authorZach Gohr <zachary.gohr@gmail.com>2013-01-09 14:26:11 -0600
committerZach Gohr <zachary.gohr@gmail.com>2013-01-09 14:26:11 -0600
commit3ccab4c0b24674115d2423b2825718be48abb695 (patch)
tree052033b91cd766c85a40f70a5f78f6566ef0d30d /wkhtmltopdf
parentba882d53aec38846fcc14acfda59b696de41df4b (diff)
downloaddjango-wkhtmltopdf-3ccab4c0b24674115d2423b2825718be48abb695.tar.gz
django-wkhtmltopdf-3ccab4c0b24674115d2423b2825718be48abb695.tar.bz2
django-wkhtmltopdf-3ccab4c0b24674115d2423b2825718be48abb695.zip
Remove duplicates when replacing file paths
Diffstat (limited to 'wkhtmltopdf')
-rw-r--r--wkhtmltopdf/views.py9
1 files changed, 7 insertions, 2 deletions
diff --git a/wkhtmltopdf/views.py b/wkhtmltopdf/views.py
index 4d0ccca..fd5b8c8 100644
--- a/wkhtmltopdf/views.py
+++ b/wkhtmltopdf/views.py
@@ -168,8 +168,13 @@ class PDFTemplateResponse(TemplateResponse, PDFResponse):
if not x['root'].endswith('/'):
x['root'] += '/'
- for occur in re.findall('''["|']({0}.*?)["|']'''.format(x['url']), content):
- content = content.replace(occur, pathname2fileurl(x['root']) + occur[len(x['url']):])
+ occurences = re.findall('''["|']({0}.*?)["|']'''.format(x['url']),
+ content)
+ occurences = list(set(occurences)) # Remove dups
+ for occur in occurences:
+ content = content.replace(occur,
+ pathname2fileurl(x['root']) +
+ occur[len(x['url']):])
return content