Language: Java
Label: vulnerable
CWE: CWE-611 \u2014 Improper Restriction of XML External Entity Reference
The product processes an XML document that can contain XML entities with URIs that resolve to documents outside of the intended sphere of control, causing the product to embed incorrect documents into its output.

Code:
	public void initializeFromMemento(String data) {
		Element root = null;
		DocumentBuilder parser;
		try {
			parser = DocumentBuilderFactory.newInstance().newDocumentBuilder();
			parser.setErrorHandler(new DefaultHandler());
			root = parser.parse(new InputSource(new StringReader(data))).getDocumentElement();

			fCollectString = root.getAttribute(COLLECT_STRING_ATTR);
			if (fCollectString == null)
				fCollectString = ""; //$NON-NLS-1$

			String asStrings = root.getAttribute(COLLECT_AS_STRING_ATTR);
			if (asStrings != null) {
				fCharPtrAsStrings = Boolean.valueOf(asStrings);
			} else {
				fCharPtrAsStrings = false;
			}

			fCharPtrAsStringsLimit = null;
			String asStringsLimit = root.getAttribute(COLLECT_AS_STRING_LIMIT_ATTR);
			if (asStringsLimit != null) {
				try {
					fCharPtrAsStringsLimit = Integer.valueOf(asStringsLimit);
				} catch (NumberFormatException e) {
					// leave as null to disable
				}
			}
		} catch (Exception e) {
			GdbPlugin.log(e);
		}
	}