  protected XMLReader installXMLFilter(XMLReader reader) {
    XMLFilter filter = getXMLFilter();

    if (filter != null) {
      // find the root XMLFilter
      XMLFilter root = filter;

      while (true) {
        XMLReader parent = root.getParent();

        if (parent instanceof XMLFilter) {
          root = (XMLFilter) parent;
        } else {
          break;
        }
      }

      root.setParent(reader);

      return filter;
    }

    return reader;
  }
The software 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.