From f4ca355c3d6aa8926e917c7bc643a1431695524a Mon Sep 17 00:00:00 2001 From: Alexander Grund Date: Sun, 13 Nov 2022 18:05:16 +0100 Subject: [PATCH] Use a RegEx to get carrier instead of XML parsing As we later do literal matches against the lines XML parsing is the wrong approach as e.g. XML excapes will not be found which causes custom APNs with e.g. `&` to be ignored, i.e. they will not overwrite the default ones and will be fully missing from the output file. Change-Id: I2bc575d4bbdc5d802c5d5b3420ee6b536a5a18fc --- tools/custom_apns.py | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/tools/custom_apns.py b/tools/custom_apns.py index b18ce1ce..270ed85f 100644 --- a/tools/custom_apns.py +++ b/tools/custom_apns.py @@ -15,8 +15,8 @@ # limitations under the License. # +import re import sys -from xml.dom.minidom import parseString def main(argv): reload(sys) @@ -32,9 +32,7 @@ def main(argv): custom_apn_names = set() with open(custom_override_file, 'r') as f: for line in f: - xmltree = parseString(line) - carrier = xmltree.getElementsByTagName('apn')[0].getAttribute('carrier') - custom_apn_names.add('carrier="' + carrier + '"') + custom_apn_names.add(re.search(r'carrier="[^"]+"', line).group(0)) with open(original_file, 'r') as input_file: with open(output_file_path, 'w') as output_file: