Skip to content

Commit baa8d8f

Browse files
committed
Whitelist +, #, ., - and – special characters
1 parent c1f3aff commit baa8d8f

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
'click==7.0',
1111
'google-api-python-client==1.6.3',
1212
'requests==2.20.0',
13-
'python-slugify==1.2.6'
13+
'python-slugify==4.0.0'
1414
]
1515

1616
dev_requirements = [

src/downloader.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import os
2+
import re
23
import sys
34
import time
45

@@ -23,7 +24,13 @@ class PacktConnectionError(ConnectionError):
2324

2425
def slugify_product_name(title):
2526
"""Return book title with spaces replaced by underscore and unicodes replaced by characters valid in filenames."""
26-
return slugify(title, separator='_', lowercase=False)
27+
return slugify(
28+
title,
29+
separator='_',
30+
lowercase=False,
31+
regex_pattern=re.compile(r'[^-a-zA-Z0-9\+\#\.\-\–]+'),
32+
replacements=[['–', '-']]
33+
)
2734

2835

2936
def wait_for_computation(predicate, timeout, retry_after):

0 commit comments

Comments
 (0)