/** * Constructor * * @param reader JspReader this mark belongs to * @param inStream current stream for this mark * @param name JSP file name */ Mark(JspReader reader, char[] inStream, String name) { this.ctxt = reader.getJspCompilationContext(); this.stream = inStream; this.cursor = 0; this.line = 1; this.col = 1; this.fileName = name; }
private void parseComment(Node parent) throws JasperException { start = reader.mark(); Mark stop = reader.skipUntil("--%>"); if (stop == null) { err.jspError(start, "jsp.error.unterminated", "<%--"); } @SuppressWarnings("unused") Node unused = new Node.Comment(reader.getText(start, stop), start, parent); }
int skipSpaces() throws JasperException { int i = 0; while (hasMoreInput() && isSpace()) { i++; nextChar(); } return i; }
boolean matchesETagWithoutLessThan(String tagName) { Mark mark = mark(); if (!matches("/" + tagName)) return false; skipSpaces(); if (nextChar() == '>') return true; setCurrent(mark); return false; }
boolean matchesETagWithoutLessThan(String tagName) throws JasperException { Mark mark = mark(); if (!matches("/" + tagName)) return false; skipSpaces(); if (nextChar() == '>') return true; reset(mark); return false; }
private void parseXMLDeclaration(Node parent) throws JasperException { reader.skipSpaces(); if (!reader.matches("/>")) { if (!reader.matches(">")) { err.jspError(start, "jsp.error.unterminated", "<jsp:declaration>"); String text; while (true) { start = reader.mark(); stop = reader.skipUntil("<"); if (stop == null) { err.jspError(start, "jsp.error.unterminated", "<jsp:declaration>"); text = parseScriptText(reader.getText(start, stop)); new Node.Declaration(text, start, parent); if (reader.matches("![CDATA[")) { start = reader.mark(); stop = reader.skipUntil("]]>"); if (stop == null) { err.jspError(start, "jsp.error.unterminated", "CDATA"); text = parseScriptText(reader.getText(start, stop)); new Node.Declaration(text, start, parent); } else { if (!reader.matchesETagWithoutLessThan("jsp:declaration")) { err.jspError(start, "jsp.error.unterminated", "<jsp:declaration>");
skipSpaces(); StringBuilder.setLength(0); if (!hasMoreInput()) { return ""; int ch = peekChar(); ch = nextChar(); for (ch = nextChar(); ch != -1 && ch != endQuote; ch = nextChar()) { if (ch == '\\') ch = nextChar(); StringBuilder.append((char) ch); err.jspError(mark(), "jsp.error.quotes.unterminated"); err.jspError(mark(), "jsp.error.attr.quoted"); if (!isDelimiter()) { ch = nextChar(); if (peekChar() == '"' || peekChar() == '\'' || peekChar() == '>' || peekChar() == '%') ch = nextChar(); } while (!isDelimiter());
private void parseOptionalBody(Node parent, String tag, String bodyType) throws JasperException { if (reader.matches("/>")) { // EmptyBody return; } if (!reader.matches(">")) { err.jspError(reader.mark(), "jsp.error.unterminated", "<" + tag); } if (reader.matchesETag(tag)) { // EmptyBody return; } if (!parseJspAttributeAndBody(parent, tag, bodyType)) { // Must be ( '>' # Body ETag ) parseBody(parent, tag, bodyType); } }
private void parseJspBody(Node parent, String bodyType) throws JasperException { Mark start = reader.mark(); Node bodyNode = new Node.JspBody(start, parent); reader.skipSpaces(); if (!reader.matches("/>")) { if (!reader.matches(">")) { err.jspError(start, "jsp.error.unterminated", "<jsp:body"); } parseBody(bodyNode, "jsp:body", bodyType); } }
inStreamReader = JspUtil.getReader(absFileName, sourceEnc, jarFile, ctxt, err, skip); JspReader jspReader = new JspReader(ctxt, absFileName, sourceEnc, inStreamReader, err);
private void parseELExpression(Node parent, char type) throws JasperException { start = reader.mark(); Mark last = reader.skipELExpression(); if (last == null) { err.jspError(start, "jsp.error.unterminated", type + "{"); } @SuppressWarnings("unused") Node unused = new Node.ELExpression(type, reader.getText(start, last), start, parent); }
private void parsePluginTags(Node parent) throws JasperException { reader.skipSpaces(); if (reader.matches("<jsp:params")) { parseJspParams(parent); reader.skipSpaces(); } if (reader.matches("<jsp:fallback")) { parseFallBack(parent); reader.skipSpaces(); } }
int peekChar() throws JasperException { if (!hasMoreInput()) return -1; return current.stream[current.cursor]; }
private void parseXMLDeclaration(Node parent) throws JasperException { reader.skipSpaces(); if (!reader.matches("/>")) { if (!reader.matches(">")) { err.jspError(start, "jsp.error.unterminated", "<jsp:declaration>"); String text; while (true) { start = reader.mark(); stop = reader.skipUntil("<"); if (stop == null) { err.jspError(start, "jsp.error.unterminated", "<jsp:declaration>"); text = parseScriptText(reader.getText(start, stop)); @SuppressWarnings("unused") Node unused = new Node.Declaration(text, start, parent); if (reader.matches("![CDATA[")) { start = reader.mark(); stop = reader.skipUntil("]]>"); if (stop == null) { err.jspError(start, "jsp.error.unterminated", "CDATA"); text = parseScriptText(reader.getText(start, stop)); @SuppressWarnings("unused") Node unused2 = new Node.Declaration(text, start, parent); if (!reader.matchesETagWithoutLessThan("jsp:declaration")) { err.jspError(start, "jsp.error.unterminated",
skipSpaces(); stringBuffer.setLength(0); if (!hasMoreInput()) { return ""; int ch = peekChar(); ch = nextChar(); for (ch = nextChar(); ch != -1 && ch != endQuote; ch = nextChar()) { if (ch == '\\') ch = nextChar(); stringBuffer.append((char) ch); err.jspError(mark(), "jsp.error.quotes.unterminated"); err.jspError(mark(), "jsp.error.attr.quoted"); if (!isDelimiter()) { ch = nextChar(); if (peekChar() == '"' || peekChar() == '\'' || peekChar() == '>' || peekChar() == '%') ch = nextChar(); } while (!isDelimiter());
boolean matchesETagWithoutLessThan(String tagName) throws JasperException { Mark mark = mark(); if (!matches("/" + tagName)) return false; skipSpaces(); if (nextChar() == '>') return true; reset(mark); return false; }
private void parseOptionalBody(Node parent, String tag, String bodyType) throws JasperException { if (reader.matches("/>")) { // EmptyBody return; } if (!reader.matches(">")) { err.jspError(reader.mark(), "jsp.error.unterminated", "<" + tag); } if (reader.matchesETag(tag)) { // EmptyBody return; } if (!parseJspAttributeAndBody(parent, tag, bodyType)) { // Must be ( '>' # Body ETag ) parseBody(parent, tag, bodyType); } }
boolean matchesETag(String tagName) throws JasperException { Mark mark = mark(); if (!matches("</" + tagName)) return false; skipSpaces(); if (nextChar() == '>') return true; setCurrent(mark); return false; }
inStreamReader = JspUtil.getReader(absFileName, sourceEnc, jarFile, ctxt, err, skip); JspReader jspReader = new JspReader(ctxt, absFileName, sourceEnc, inStreamReader, err);
private void parseXMLScriptlet(Node parent) throws JasperException { reader.skipSpaces(); if (!reader.matches("/>")) { if (!reader.matches(">")) { err.jspError(start, "jsp.error.unterminated", "<jsp:scriptlet>"); String text; while (true) { start = reader.mark(); stop = reader.skipUntil("<"); if (stop == null) { err.jspError(start, "jsp.error.unterminated", "<jsp:scriptlet>"); text = parseScriptText(reader.getText(start, stop)); @SuppressWarnings("unused") Node unused = new Node.Scriptlet(text, start, parent); if (reader.matches("![CDATA[")) { start = reader.mark(); stop = reader.skipUntil("]]>"); if (stop == null) { err.jspError(start, "jsp.error.unterminated", "CDATA"); text = parseScriptText(reader.getText(start, stop)); @SuppressWarnings("unused") Node unused2 = new Node.Scriptlet(text, start, parent); if (!reader.matchesETagWithoutLessThan("jsp:scriptlet")) { err.jspError(start, "jsp.error.unterminated",