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:
committed by
Jan Altensen (Stricted)
parent
173af3e2f9
commit
f4ca355c3d
@@ -15,8 +15,8 @@
|
|||||||
# limitations under the License.
|
# limitations under the License.
|
||||||
#
|
#
|
||||||
|
|
||||||
|
import re
|
||||||
import sys
|
import sys
|
||||||
from xml.dom.minidom import parseString
|
|
||||||
|
|
||||||
def main(argv):
|
def main(argv):
|
||||||
reload(sys)
|
reload(sys)
|
||||||
@@ -32,9 +32,7 @@ def main(argv):
|
|||||||
custom_apn_names = set()
|
custom_apn_names = set()
|
||||||
with open(custom_override_file, 'r') as f:
|
with open(custom_override_file, 'r') as f:
|
||||||
for line in f:
|
for line in f:
|
||||||
xmltree = parseString(line)
|
custom_apn_names.add(re.search(r'carrier="[^"]+"', line).group(0))
|
||||||
carrier = xmltree.getElementsByTagName('apn')[0].getAttribute('carrier')
|
|
||||||
custom_apn_names.add('carrier="' + carrier + '"')
|
|
||||||
|
|
||||||
with open(original_file, 'r') as input_file:
|
with open(original_file, 'r') as input_file:
|
||||||
with open(output_file_path, 'w') as output_file:
|
with open(output_file_path, 'w') as output_file:
|
||||||
|
Reference in New Issue
Block a user