Skip to content

Commit

Permalink
Slashes can be used in Confluence pages now.
Browse files Browse the repository at this point in the history
  • Loading branch information
thomai committed Aug 18, 2016
1 parent 837373b commit cb8583f
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
2 changes: 1 addition & 1 deletion confluence_dumper.py
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ def fetch_page_recursively(page_id, folder_path, download_folder, html_template,
print('%sPAGE: %s (%s)' % ('\t'*(depth+1), page_title, page_id))

# Remember this file and all children
file_name = '%s.html' % utils.encode_url(page_title)
file_name = '%s.html' % utils.encode_url(utils.escape_slashes(page_title))
path_collection = {'file_path': file_name, 'page_title': page_title, 'child_pages': [], 'child_attachments': []}

# Download attachments of this page
Expand Down
9 changes: 9 additions & 0 deletions utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,15 @@ def encode_url(decoded_url):
return urllib.quote(decoded_url.encode('utf8')).encode('utf8')


def escape_slashes(unescaped_string):
""" Escapes slashes to avoid file path injection
:param unescaped_string: String to escape
:returns: Escaped string
"""
return unescaped_string.replace('/', 'SLASH')


def is_file_format(file_name, file_extensions):
""" Checks whether the extension of the given file is in a list of file extensions.
Expand Down

0 comments on commit cb8583f

Please sign in to comment.