# Buggy code
def get_browsable_activities(node):
    """Get Browsable Activities"""
    try:
        browse_dic = {}
        schemes = []
        mime_types = []
        hosts = []
        ports = []
        paths = []
        path_prefixs = []
        path_patterns = []
        catg = node.getElementsByTagName("category")
        for cat in catg:
            if cat.getAttribute("android:name") == "android.intent.category.BROWSABLE":
                datas = node.getElementsByTagName("data")
                for data in datas:
                    scheme = data.getAttribute("android:scheme")
                    if scheme and scheme not in schemes:
                        schemes.append(scheme)
                    mime = data.getAttribute("android:mimeType")
                    if mime and mime not in mime_types:
                        mime_types.append(mime)
                    host = data.getAttribute("android:host")
                    if host and host not in hosts:
                        hosts.append(host)
                    port = data.getAttribute("android:port")
                    if port and port not in ports:
                        ports.append(port)
                    path = data.getAttribute("android:path")
                    if path and path not in paths:
                        paths.append(path)
                    path_prefix = data.getAttribute("android:pathPrefix")
                    if path_prefix and path_prefix not in path_prefixs:
                        path_prefixs.append(path_prefix)
                    path_pattern = data.getAttribute("android:pathPattern")
                    if path_pattern and path_pattern not in path_patterns:
                        path_patterns.append(path_pattern)
        schemes = [scheme + "://" for scheme in schemes]
        browse_dic["schemes"] = schemes
        browse_dic["mime_types"] = mime_types
        browse_dic["hosts"] = hosts
        browse_dic["ports"] = ports
        browse_dic["paths"] = paths
        browse_dic["path_prefixs"] = path_prefixs
        browse_dic["path_patterns"] = path_patterns
        browse_dic["browsable"] = bool(browse_dic["schemes"])
        return browse_dic
    except:
        PrintException("[ERROR] Getting Browsable Activities")


# Traceback (KeyError)
[INFO] 08/Feb/2019 16:17:54 - VM Starting
[INFO] 08/Feb/2019 16:17:55 - "POST /DynamicAnalyzer/ HTTP/1.1" 200 32400
[INFO] 08/Feb/2019 16:17:55 - "GET /static/css/devices.min.css HTTP/1.1" 200 44241
[INFO] 08/Feb/2019 16:17:55 - "GET /download/screen/screen.png HTTP/1.1" 302 0
[DEBUG] 08/Feb/2019 16:17:55 - Exception while resolving variable 'exp' in template 'general/error.html'.
Traceback (most recent call last):
File "/home/userhome/Mobile-Security-Framework-MobSF/venv/lib/python3.6/site-packages/django/template/base.py", line 829, in _resolve_lookup
current = current[bit]
File "/home/userhome/Mobile-Security-Framework-MobSF/venv/lib/python3.6/site-packages/django/template/context.py", line 83, in __getitem__
raise KeyError(key)
KeyError: 'exp'

During handling of the above exception, another exception occurred:

# Fixed code
def get_browsable_activities(node):
    """Get Browsable Activities"""
    try:
        browse_dic = {}
        schemes = []
        mime_types = []
        hosts = []
        ports = []
        paths = []
        path_prefixs = []
        path_patterns = []
        catg = node.getElementsByTagName("category")
        for cat in catg:
            if cat.getAttribute("android:name") == "android.intent.category.BROWSABLE":
                datas = node.getElementsByTagName("data")
                for data in datas:
                    scheme = data.getAttribute("android:scheme")
                    if scheme and scheme not in schemes:
                        schemes.append(scheme)
                    mime = data.getAttribute("android:mimeType")
                    if mime and mime not in mime_types:
                        mime_types.append(mime)
                    host = data.getAttribute("android:host")
                    if host and host not in hosts:
                        hosts.append(host)
                    port = data.getAttribute("android:port")
                    if port and port not in ports:
                        ports.append(port)
                    path = data.getAttribute("android:path")
                    if path and path not in paths:
                        paths.append(path)
                    path_prefix = data.getAttribute("android:pathPrefix")
                    if path_prefix and path_prefix not in path_prefixs:
                        path_prefixs.append(path_prefix)
                    path_pattern = data.getAttribute("android:pathPattern")
                    if path_pattern and path_pattern not in path_patterns:
                        path_patterns.append(path_pattern)
        schemes = [scheme + "://" for scheme in schemes]
        browse_dic["schemes"] = schemes
        browse_dic["mime_types"] = mime_types
        browse_dic["hosts"] = hosts
        browse_dic["ports"] = ports
        browse_dic["paths"] = paths
        browse_dic["path_prefixs"] = path_prefixs
        browse_dic["path_patterns"] = path_patterns
        browse_dic["browsable"] = bool(browse_dic["schemes"])
        return browse_dic
    except:
        PrintException("Getting Browsable Activities")