Author
|
zPlus <zplus@peers.community>
2023-11-25 14:10:55
|
Committer
|
zPlus <zplus@peers.community>
2023-11-25 14:10:55
|
Commit
|
3c73287
(patch)
|
Tree
|
52e554e
|
Parent(s)
|
|
%-encode spaces instead of replacing with underscore.
commits diff:
a0539d8..3c73287
1 file changed,
7 insertions,
6 deletions
—
download
Diffstat
Diff options
+7/-6
M scripts/rdf.py
21
|
21
|
|
|
22
|
22
|
|
def percent_encode(string):
|
23
|
23
|
|
"""
|
24
|
|
- |
A few manpages contain special characters that are not valid symbols in a URL's
|
25
|
|
- |
path. Since we use node URIs like <dokk:manpages:distro/package/name>, we need
|
26
|
|
- |
to percent-encode these otherwise the URLs are invalid.
|
27
|
|
- |
The reason for using a custom method instead of urllib.parse.quote() is that quote()
|
28
|
|
- |
will percent-encode *any* non-ASCII character.
|
|
24
|
+ |
A few manpages contain special characters in their name that are not valid in a URL's
|
|
25
|
+ |
path. Since we use node URIs like <dokk:manpages:distro/package/name> we need to
|
|
26
|
+ |
%-encode these, otherwise the URLs are invalid.
|
|
27
|
+ |
The reason for using a custom method instead of urllib.parse.quote() is that urllib
|
|
28
|
+ |
only works with URLs but not IRIs, therefore quote() will %-encode *any* non-ASCII
|
|
29
|
+ |
character.
|
29
|
30
|
|
"""
|
30
|
31
|
|
|
31
|
|
- |
return string.replace(' ', '_') \
|
|
32
|
+ |
return string.replace(' ', '%20') \
|
32
|
33
|
|
.replace('#', '%23') \
|
33
|
34
|
|
.replace('[', '%5B') \
|
34
|
35
|
|
.replace(']', '%5D')
|