{"record":{"id":"8dcf0070acdd5680","repo":"MuntashirAkon/AppManager","slug":"unknown-entity-entity","errorCode":null,"errorMessage":"Unknown entity ${entity}","messagePattern":"Unknown entity (.+?)","errorType":"exception","errorClass":"org.xmlpull.v1.XmlPullParserException","httpStatus":null,"severity":"error","filePath":"libcore/compat/src/main/java/io/github/muntashirakon/compat/xml/BinaryXmlPullParser.java","lineNumber":342,"sourceCode":"                    return;\n            }\n        }\n    }\n\n    static @NonNull String resolveEntity(@NonNull String entity)\n            throws XmlPullParserException {\n        switch (entity) {\n            case \"lt\": return \"<\";\n            case \"gt\": return \">\";\n            case \"amp\": return \"&\";\n            case \"apos\": return \"'\";\n            case \"quot\": return \"\\\"\";\n        }\n        if (entity.length() > 1 && entity.charAt(0) == '#') {\n            final char c = (char) Integer.parseInt(entity.substring(1));\n            return new String(new char[] { c });\n        }\n        throw new XmlPullParserException(\"Unknown entity \" + entity);\n    }\n\n    @Override\n    public void require(int type, String namespace, String name)\n            throws XmlPullParserException, IOException {\n        if (namespace != null && !namespace.isEmpty()) throw illegalNamespace();\n        if (mCurrentToken != type || !Objects.equals(mCurrentName, name)) {\n            throw new XmlPullParserException(getPositionDescription());\n        }\n    }\n\n    @Override\n    public String nextText() throws XmlPullParserException, IOException {\n        if (getEventType() != START_TAG) {\n            throw new XmlPullParserException(getPositionDescription());\n        }\n        int eventType = next();\n        if (eventType == TEXT) {","sourceCodeStart":324,"sourceCodeEnd":360,"githubUrl":"https://github.com/MuntashirAkon/AppManager/blob/0152f468fc9463ee02dc2ca83f6fe4989a2c4ca5/libcore/compat/src/main/java/io/github/muntashirakon/compat/xml/BinaryXmlPullParser.java#L324-L360","documentation":"resolveEntity() maps the small set of predefined XML entities (amp, lt, gt, apos, quot) plus numeric character references (#123;) to characters. Any other entity name in a binary XML TEXT node has no defined meaning, so an XmlPullParserException \"Unknown entity <entity>\" is thrown.","triggerScenarios":"consumeToken() reads a TEXT token whose resolved entity name is not one of the five predefined XML entities and does not start with '#' as a numeric character reference — i.e. named entities like &nbsp; or custom entities embedded in the binary stream.","commonSituations":"Documents converted from text XML that contained HTML-style named entities (&nbsp;, &copy;) before binary encoding; tooling that wrote entities verbatim without escaping/resolving them; hand-crafted binary XML containing unsupported entity names.","solutions":["Replace named HTML entities with the actual characters or numeric character references (&#160; for &nbsp;) in the source document before binary encoding.","Pre-process text content to resolve entities with a text XML parser before writing binary XML.","If you control the writer, escape only the five predefined XML entities."],"exampleFix":"// before\n// binary XML contains: \"hello&nbsp;world\" -> Unknown entity nbsp\n// after\n// source text: \"hello\\u00A0world\" or \"hello&#160;world\"","handlingStrategy":"validation","validationCode":"static boolean isSupportedEntity(String name) {\n    return name.equals(\"amp\") || name.equals(\"lt\") || name.equals(\"gt\")\n        || name.equals(\"apos\") || name.equals(\"quot\")\n        || (name.length() > 1 && name.charAt(0) == '#');\n}","typeGuard":null,"tryCatchPattern":"try {\n    parser.setInput(is, null);\n    // parse text nodes\n} catch (XmlPullParserException e) {\n    if (e.getMessage().startsWith(\"Unknown entity\")) {\n        // sanitize source text and re-encode the document\n    }\n}","preventionTips":["Use only the five predefined XML entities or numeric character references in source text.","Resolve HTML named entities (&nbsp;, &copy;) before binary encoding.","Sanitize text content at the writing stage so entities never reach the binary format."],"tags":["xml","entity","parse-error","text"],"backgroundTag":"entity-not-found","analyzedSha":"0152f468fc9463ee02dc2ca83f6fe4989a2c4ca5","analyzedAt":"2026-09-12T14:03:37.243Z","contentChangedAt":"2026-09-12T14:03:37.243Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}