Skip to content

Commit

Permalink
Whitelist +, #, ., - and – special characters
Browse files Browse the repository at this point in the history
  • Loading branch information
mjenczmyk committed Mar 18, 2020
1 parent c1f3aff commit baa8d8f
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
'click==7.0',
'google-api-python-client==1.6.3',
'requests==2.20.0',
'python-slugify==1.2.6'
'python-slugify==4.0.0'
]

dev_requirements = [
Expand Down
9 changes: 8 additions & 1 deletion src/downloader.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import os
import re
import sys
import time

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

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


def wait_for_computation(predicate, timeout, retry_after):
Expand Down

0 comments on commit baa8d8f

Please sign in to comment.