You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@cocoon.apache.org by Nicols Lichtmaier <ni...@debian.org> on 2001/02/22 03:50:24 UTC

[C1] [patch] The cocoon "advertising" shouldn't be in documents which don't allow it

 There are many text/* content types that doesn't accept <!--  markup as a
comment. The default should be to do nothing, and to only add markup if we
positively know it will be ignored.

 I've added an allowsMarkup() method to the Page class. If you know other
common content-types which allow markup, please include them (does XHTML use
another one?).

Index: Engine.java
===================================================================
RCS file: /home/cvspublic/xml-cocoon/src/org/apache/cocoon/Engine.java,v
retrieving revision 1.50
diff -u -r1.50 Engine.java
--- Engine.java	2001/01/24 15:52:22	1.50
+++ Engine.java	2001/02/22 02:38:50
@@ -467,7 +467,7 @@
                 // if verbose mode is on, the output type allows it
                 // and the HTTP request isn't a HEAD
                 // print some processing info as a comment
-                if (VERBOSE && (page.isText()) && !"HEAD".equals(request.getMethod())) {
+                if (VERBOSE && (page.allowsMarkup()) && !"HEAD".equals(request.getMethod())) {
                     time = System.currentTimeMillis() - time;
                     String comment = "\n<!-- This page was served "
                         + (wasInCache ? "from cache " : "")
Index: framework/Page.java
===================================================================
RCS file: /home/cvspublic/xml-cocoon/src/org/apache/cocoon/framework/Page.java,v
retrieving revision 1.6
diff -u -r1.6 Page.java
--- framework/Page.java	2000/12/22 11:51:08	1.6
+++ framework/Page.java	2001/02/22 02:38:50
@@ -89,6 +89,13 @@
     	return this.contentType.startsWith("text");
     }
     
+    public boolean allowsMarkup() {
+        return contentType.equals("text/xml")
+	        || contentType.equals("text/html")
+	        || contentType.equals("text/svg")
+	        || contentType.equals("text/mathml");
+    }
+    
     public Enumeration getChangeables() {
         return this.changeables.elements();
     }