mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
Fix local file download by encoding URL
Properly encode links to files with special characters for the user to actually be able to download them. The issue still remains for image files but the logic path is quite different than with other files fix might involve changes to docutils. Fixes sphinx-doc/sphinx#3097 Signed-off-by: Johannes Aalto <ext-johannes.aalto@vaisala.com>
This commit is contained in:
parent
fa3b334ed0
commit
b2bd115dc8
@ -12,6 +12,7 @@ import copy
|
||||
import os
|
||||
import posixpath
|
||||
import re
|
||||
import urllib.parse
|
||||
import warnings
|
||||
from typing import TYPE_CHECKING, Iterable, Tuple, cast
|
||||
|
||||
@ -589,7 +590,8 @@ class HTMLTranslator(SphinxTranslator, BaseTranslator):
|
||||
self.context.append('</a>')
|
||||
elif 'filename' in node:
|
||||
atts['class'] += ' internal'
|
||||
atts['href'] = posixpath.join(self.builder.dlpath, node['filename'])
|
||||
atts['href'] = posixpath.join(self.builder.dlpath,
|
||||
urllib.parse.quote(node['filename']))
|
||||
self.body.append(self.starttag(node, 'a', '', **atts))
|
||||
self.context.append('</a>')
|
||||
else:
|
||||
|
@ -11,6 +11,7 @@
|
||||
import os
|
||||
import posixpath
|
||||
import re
|
||||
import urllib.parse
|
||||
import warnings
|
||||
from typing import TYPE_CHECKING, Iterable, Tuple, cast
|
||||
|
||||
@ -529,7 +530,8 @@ class HTML5Translator(SphinxTranslator, BaseTranslator):
|
||||
self.context.append('</a>')
|
||||
elif 'filename' in node:
|
||||
atts['class'] += ' internal'
|
||||
atts['href'] = posixpath.join(self.builder.dlpath, node['filename'])
|
||||
atts['href'] = posixpath.join(self.builder.dlpath,
|
||||
urllib.parse.quote(node['filename']))
|
||||
self.body.append(self.starttag(node, 'a', '', **atts))
|
||||
self.context.append('</a>')
|
||||
else:
|
||||
|
Loading…
Reference in New Issue
Block a user