mirror of
https://github.com/f-droid/fdroidserver.git
synced 2025-11-04 14:30:30 +03:00
index.xml: XML escaping from Python < 3.13 which stopped converting "
index.xml is for old clients that are stuck in the past forever. So the
format should not change at all. Python 3.13 changed minidom so it no
longer converts " to an XML entity.
154477be72
This commit is contained in:
parent
6d40e8fa27
commit
bc118484e4
1 changed files with 24 additions and 0 deletions
|
|
@ -28,6 +28,7 @@ import os
|
|||
import re
|
||||
import ruamel.yaml
|
||||
import shutil
|
||||
import sys
|
||||
import tempfile
|
||||
import urllib.parse
|
||||
import zipfile
|
||||
|
|
@ -1309,6 +1310,29 @@ def make_v0(apps, apks, repodir, repodict, requestsdict, fdroid_signing_key_fing
|
|||
os.remove(siglinkname)
|
||||
os.symlink(sigfile_path, siglinkname)
|
||||
|
||||
if sys.version_info.minor >= 13:
|
||||
# Python 3.13 changed minidom so it no longer converts " to an XML entity.
|
||||
# https://github.com/python/cpython/commit/154477be722ae5c4e18d22d0860e284006b09c4f
|
||||
# This just puts back the previous implementation, with black code format.
|
||||
import inspect
|
||||
import xml.dom.minidom
|
||||
|
||||
def _write_data(writer, text, attr): # pylint: disable=unused-argument
|
||||
if text:
|
||||
text = (
|
||||
text.replace('&', '&')
|
||||
.replace('<', '<')
|
||||
.replace('"', '"')
|
||||
.replace('>', '>')
|
||||
)
|
||||
writer.write(text)
|
||||
|
||||
argnames = tuple(inspect.signature(xml.dom.minidom._write_data).parameters)
|
||||
if argnames == ('writer', 'text', 'attr'):
|
||||
xml.dom.minidom._write_data = _write_data
|
||||
else:
|
||||
logging.warning('Failed to monkey patch minidom for index.xml support!')
|
||||
|
||||
if common.options.pretty:
|
||||
output = doc.toprettyxml(encoding='utf-8')
|
||||
else:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue