martin-g commented on a change in pull request #351: URL: https://github.com/apache/tomcat/pull/351#discussion_r494079321
########## File path: java/org/apache/jasper/compiler/Generator.java ########## @@ -2095,6 +2101,20 @@ public void visit(Node.JspElement n) throws JasperException { public void visit(Node.TemplateText n) throws JasperException { String text = n.getText(); + // If the flag is active, attempt to minimize the frequency of + // regex operations. + if ((ctxt!=null) && + ctxt.getOptions().getJSPWhiteSpaceTrimFlag() && + text.contains("\n")) { + // Ensure there are no <pre> or </pre> tags embedded in this + // text - if there are, we want to NOT modify the whitespace. + Matcher preMatcher = PRE_TAG_PATTERN.matcher(text); + if (!preMatcher.matches()) { + Matcher matcher = BLANK_LINE_PATTERN.matcher(text); + String revisedText = matcher.replaceAll("\n"); Review comment: This will drop also any `\r`s in the string. Is this intentional ? ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org For additional commands, e-mail: dev-h...@tomcat.apache.org