Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def _init_manifest(self):
ANDROID_MANIFEST = "AndroidManifest.xml"
try:
with zipfile.ZipFile(self.apk_path, mode="r") as zf:
if ANDROID_MANIFEST in zf.namelist():
zipinfo = zf.getinfo(ANDROID_MANIFEST)
zipinfo.flag_bits = 0
data = zf.read(ANDROID_MANIFEST)
try:
axml = AXML(data)
if axml.is_valid:
self.org_manifest = axml.get_xml()
self.manifest = xmltodict.parse(
self.org_manifest)['manifest']
except Exception as e:
raise e
except Exception as e:
raise e
def _init_org_manifest(self):
ANDROID_MANIFEST = "AndroidManifest.xml"
try:
with apkfile.ZipFile(self.apk_path, mode="r") as zf:
if ANDROID_MANIFEST in zf.namelist():
data = zf.read(ANDROID_MANIFEST)
try:
axml = AXML(data)
if axml.is_valid:
self.org_manifest = axml.get_xml()
except Exception as e:
raise e
except Exception as e:
raise e
# fix manifest
self.org_manifest = re.sub(
r'\s:(="[\w]*?\.[\.\w]*")', r' android:name\1', self.org_manifest)