From 8fed2de66e767f72ae133866d69fc3f0cd7ad9f5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andreas=20Sch=C3=A4rtl?= <andreas@schaertl.me> Date: Tue, 28 Apr 2020 18:28:13 +0000 Subject: [PATCH] fix-rdf-file: don't use uri escape We'll have to get an iri lib or better yet fix the export in the long run. --- ulo/fix-rdf-file.py | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/ulo/fix-rdf-file.py b/ulo/fix-rdf-file.py index d12a36e..9bb25ad 100755 --- a/ulo/fix-rdf-file.py +++ b/ulo/fix-rdf-file.py @@ -8,10 +8,20 @@ import sys def fix_quoted(s: str) -> str: payload = s.strip('"') - fixed = parse.quote(payload) - fixed = fixed.replace('http%3A', 'http:') - fixed = fixed.replace('https%3A', 'https:') - return '"%s"' % fixed + + #fixed = parse.quote(payload) + #fixed = fixed.replace('http%3A', 'http:') + #fixed = fixed.replace('https%3A', 'https:') + + bad_chars = ( + '|', '\\', ' ', '^' + ) + + for c in bad_chars: + escaped = '%' + '%X' % ord(c) + payload = payload.replace(c, escaped) + + return '"%s"' % payload def print_fixed_line(line: str): -- GitLab