/** * {@inheritDoc} */ @Override protected void abortInjectionPointSearch() { super.abortInjectionPointSearch(); leftOver = NO_LEFTOVER_CHARACTER_BYTES; encodeBuffer = null; // NOPMD decodeBuffer = null; // NOPMD }
/** * Tries to find an opening body tag. Omitting both the head and the body tag is currently not * supported. */ private void scanForBodyTag() { if (CharSequenceUtils.checkEqualIgnoreCase(tokenParser.getTagType(), "body")) { if (tokenParser.getParsedTokenType() != Token.START_TAG) { abortInjectionPointSearch(); return; } // Perform injection after start of the head tag status = Status.INJECTION_POINT_FOUND; } else { // current token is not the head tag, we assume it must be the body tag (head is empty) abortInjectionPointSearch(); } }
/** * Same as {@link #scanHtmlPreamble()}, however does not allow to ommit the preamble. */ private void scanRequiredXHtmlPreamble() { // Preamble checking based on the information on this page // http://wiki.selfhtml.org/wiki/HTML/Dokumentstruktur_und_Aufbau#HTML5 // we also allow html without preamble, directly starting with the <html> tag if (CharSequenceUtils.checkEqualIgnoreCase(tokenParser.getTagType(), "!DOCTYPE")) { // Doctypes are formated as opening tags if (tokenParser.getParsedTokenType() != Token.START_TAG) { abortInjectionPointSearch(); return; } // we accept any doctype starting with "html" if (!CharSequenceUtils.checkEqualIgnoreCase(tokenParser.getTagArguments(), 0, 4, "html", 0, 4)) { abortInjectionPointSearch(); return; } // DOCTYPE okay, proceed with the next tag scanning for the html tag status = Status.SCAN_FOR_HTML_TAG; } else { // no preamble tag found, it however is required for xhtml abortInjectionPointSearch(); return; } }
/** * Scans for an opening html tag, skipping preamble tags like or !DOCTYPE. */ private void scanHtmlPreamble() { // Preamble checking based on the information on this page // http://wiki.selfhtml.org/wiki/HTML/Dokumentstruktur_und_Aufbau#HTML5 // we also allow html without preamble, directly starting with the <html> tag if (CharSequenceUtils.checkEqualIgnoreCase(tokenParser.getTagType(), "!DOCTYPE")) { // Doctypes are formated as opening tags if (tokenParser.getParsedTokenType() != Token.START_TAG) { abortInjectionPointSearch(); return; } // we accept any doctype starting with "html" if (!CharSequenceUtils.checkEqualIgnoreCase(tokenParser.getTagArguments(), 0, 4, "html", 0, 4)) { abortInjectionPointSearch(); return; } // DOCTYPE okay, proceed with the next tag scanning for the html tag status = Status.SCAN_FOR_HTML_TAG; } else { // no preamble tag found, we assume the html is starting immediately status = Status.SCAN_FOR_HTML_TAG; processToken(); } }
/** * Tries to find an opening html tag. */ private void scanForHtmlTag() { if (CharSequenceUtils.checkEqualIgnoreCase(tokenParser.getTagType(), "html")) { if (tokenParser.getParsedTokenType() != Token.START_TAG) { abortInjectionPointSearch(); return; } status = Status.SCAN_FOR_HEAD_TAG; } else { // current token is not the html tag, we assume the document starts immediately with the // head status = Status.SCAN_FOR_HEAD_TAG; processToken(); } }
/** * Tries to find an opening head tag. Omitting both the head and the body tag is currently not * supported. */ private void scanForHeadTag() { if (CharSequenceUtils.checkEqualIgnoreCase(tokenParser.getTagType(), "head")) { if (tokenParser.getParsedTokenType() != Token.START_TAG) { abortInjectionPointSearch(); return; } // Perform injection after start of the head tag status = Status.INJECTION_POINT_FOUND; } else { // current token is not the head tag, we assume it must be the body tag (head is empty) status = Status.SCAN_FOR_BODY_TAG; processToken(); } }
/** * Scans for an opening <?xml .. ?> declaration in case the html is delivered as XML. */ private void scanXmlDeclaration() { // Preamble checking based on the information on this page if (CharSequenceUtils.checkEqualIgnoreCase(tokenParser.getTagType(), "?xml")) { // ?> is treated by the parser as a stand-alone tag if (tokenParser.getParsedTokenType() != Token.STANDALONE_TAG) { abortInjectionPointSearch(); return; } // Xml header detected, now we require an html doctype to continue status = Status.SCAN_REQUIRED_XHTML_PREAMBLE; } else { // no xml tag found, therefore we are non-strict in requiring a doctype declaration status = Status.SCAN_HTML_PREAMBLE; processToken(); } }
switch (tokenParsingResult) { case FAILURE: abortInjectionPointSearch(); return null; case INCOMPLETE: abortInjectionPointSearch(); return returnValue; } else if (status != Status.TERMINATED) {