Commit bd079c93 authored by Hans-Christoph Steiner's avatar Hans-Christoph Steiner
Browse files

Merge branch 'NoahAndrews-master-patch-97157' into 'master'

Handle error when parsing WebView icon

Closes #903

See merge request !1018
parents 80d23818 75989ff5
Pipeline #380987324 passed with stages
in 17 minutes and 13 seconds
......@@ -1543,8 +1543,8 @@ def scan_apk_androguard(apk, apkfile):
icon_id_str = apkobject.get_element("application", "icon")
if icon_id_str:
icon_id = int(icon_id_str.replace("@", "0x"), 16)
icon_id = int(icon_id_str.replace("@", "0x"), 16)
resource_id = arsc.get_id(apk['packageName'], icon_id)
if resource_id:
icon_name = arsc.get_id(apk['packageName'], icon_id)[1]
......@@ -843,6 +843,40 @@ class UpdateTest(unittest.TestCase):
with self.assertRaises(fdroidserver.exception.BuildException):
os.path.exists('tests/SystemWebView-repack.apk'), "file too big for sdist"
def test_scan_apk_bad_icon_id(self):
"""Some APKs can produce an exception when extracting the icon
This kind of parsing exception should be reported then ignored
so that working APKs can be included in the index. There are
so many weird things that make it into APKs, that does not
automatically disqualify them from inclusion. For example:
ValueError: invalid literal for int() with base 16: '<0x801FF, type 0x07>'
The test APK was made from:
It was then stripped down by doing:
* mkdir SystemWebView
* cd SystemWebView/
* unzip ../SystemWebView.apk
* rm -rf META-INF/ lib assets/icudtl.dat assets/stored-locales/
* jar cf ../SystemWebView-repack.apk *
# reset the state, perhaps this should be in setUp()
config = dict()
fdroidserver.common.config = config
fdroidserver.update.config = config
with tempfile.TemporaryDirectory() as tmpdir, TmpCwd(tmpdir):
apkfile = 'repo/SystemWebView-repack.apk'
shutil.copy(os.path.join(self.basedir, os.path.basename(apkfile)), apkfile)
def test_process_apk(self):
def _build_yaml_representer(dumper, data):
'''Creates a YAML representation of a Build instance'''
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment