aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJames Turnbull <james@jamesturnbull.org>2013-01-10 01:57:38 -0800
committerJames Turnbull <james@jamesturnbull.org>2013-01-10 01:57:38 -0800
commitb4b98ee420ca4774459a73b8cecd1d20627f1235 (patch)
tree052033b91cd766c85a40f70a5f78f6566ef0d30d
parentba882d53aec38846fcc14acfda59b696de41df4b (diff)
parent3ccab4c0b24674115d2423b2825718be48abb695 (diff)
downloaddjango-wkhtmltopdf-b4b98ee420ca4774459a73b8cecd1d20627f1235.tar.gz
django-wkhtmltopdf-b4b98ee420ca4774459a73b8cecd1d20627f1235.tar.bz2
django-wkhtmltopdf-b4b98ee420ca4774459a73b8cecd1d20627f1235.zip
Merge pull request #25 from zgohr/duplicates
Remove duplicates when replacing file paths
-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