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
This commit is contained in:
Alexander Grund
2022-11-13 18:05:16 +01:00
committed by Jan Altensen (Stricted)
parent 173af3e2f9
commit f4ca355c3d

View File

@@ -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: