cocoon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From giac...@apache.org
Subject svn commit: r106286 - /cocoon/trunk/src/documentation/xdocs/userdocs/transformers/encodeurl-transformer.xml /cocoon/trunk/src/java/org/apache/cocoon/transformation/EncodeURLTransformer.java
Date Tue, 23 Nov 2004 07:55:29 GMT
Author: giacomo
Date: Mon Nov 22 23:55:29 2004
New Revision: 106286

Modified:
   cocoon/trunk/src/documentation/xdocs/userdocs/transformers/encodeurl-transformer.xml
   cocoon/trunk/src/java/org/apache/cocoon/transformation/EncodeURLTransformer.java
Log:
add value to pattern, too

Modified: cocoon/trunk/src/documentation/xdocs/userdocs/transformers/encodeurl-transformer.xml
Url: http://svn.apache.org/viewcvs/cocoon/trunk/src/documentation/xdocs/userdocs/transformers/encodeurl-transformer.xml?view=diff&rev=106286&p1=cocoon/trunk/src/documentation/xdocs/userdocs/transformers/encodeurl-transformer.xml&r1=106285&p2=cocoon/trunk/src/documentation/xdocs/userdocs/transformers/encodeurl-transformer.xml&r2=106286
==============================================================================
--- cocoon/trunk/src/documentation/xdocs/userdocs/transformers/encodeurl-transformer.xml	(original)
+++ cocoon/trunk/src/documentation/xdocs/userdocs/transformers/encodeurl-transformer.xml	Mon
Nov 22 23:55:29 2004
@@ -42,9 +42,10 @@
    </p>
    <p>
     You can specify which attributes hold URL values in order to restrict
-    URL rewriting to specific attributes only. In the current implementation
+    URL rewriting to specific attributes and values only. In the current implementation
     you specify include, and exclude patterns as regular expressions, concatting
-    element-name + "/@" + attribute-name.
+    element-name-regexp + "/@" + attribute-name-regexp [ + "=" + attribute-value-regexp ]

+    whereas the part in brackets [] are optional.
    </p>
    <p>
     The EncodeURLTransformer has several configuration options. These options
@@ -52,9 +53,10 @@
    </p>
    <dl>
      <dt>include-name</dt>
-     <dd>RE pattern for including attributes from encode URL rewriting, 
+     <dd>RE pattern for including attributes for encode URL rewriting, 
        The attribute values are encoded, if an 
-       expressions of the form <code>element-name/@attribute-name</code>
+       expressions of the form 
+       <code>element-name-regexp/@attribute-name-regexp[=attribute-value-regexp]</code>
        matches.
        <br/>
        By default <code>include-name</code> is defined as
@@ -63,7 +65,8 @@
      <dt>exclude-name</dt>
      <dd>RE pattern for excluding attributes from encode URL rewriting,
        The attribute values are not encoded, if an 
-       expressions of the form <code>element-name/@attribute-name</code>
+       expressions of the form 
+       <code>element-name-regexp/@attribute-name-regexp[=attribute-value-regexp]</code>
        matches.
        <br/>
        By default <code>exclude-name</code> is defined as
@@ -91,7 +94,7 @@
       src="org.apache.cocoon.transformation.EncodeURLTransformer">
       <!-- default configuration, explicitly defined -->
       <include-name>.*/@href|.*/@action|frame/@src</include-name>
-      <exclude-name>img/@src</exclude-name>
+      <exclude-name>img/@src|(a/@href|iframe/@src)=.*adserver</exclude-name>
     </map:transformer>
   ...
 ]]></source>

Modified: cocoon/trunk/src/java/org/apache/cocoon/transformation/EncodeURLTransformer.java
Url: http://svn.apache.org/viewcvs/cocoon/trunk/src/java/org/apache/cocoon/transformation/EncodeURLTransformer.java?view=diff&rev=106286&p1=cocoon/trunk/src/java/org/apache/cocoon/transformation/EncodeURLTransformer.java&r1=106285&p2=cocoon/trunk/src/java/org/apache/cocoon/transformation/EncodeURLTransformer.java&r2=106286
==============================================================================
--- cocoon/trunk/src/java/org/apache/cocoon/transformation/EncodeURLTransformer.java	(original)
+++ cocoon/trunk/src/java/org/apache/cocoon/transformation/EncodeURLTransformer.java	Mon Nov
22 23:55:29 2004
@@ -75,7 +75,7 @@
  *     ...
  *       &lt;map:transformer type=&quot;encodeURL&quot;
  *         src=&quot;org.apache.cocoon.optional.transformation.EncodeURLTransformer&quot;&gt;
- *         &lt;exclude-name&gt;img/@src&lt;/exclude-name&gt;
+ *         &lt;exclude-name&gt;img/@src|a/@href=.&amp;asterik;adserver&lt;/exclude-name&gt;
  *         &lt;include-name&gt;.&amp;asterik;/@href|.&amp;asterik;/@src|.&amp;asterik;/@action&lt;/include-name&gt;
  *       &lt;/map:transformer&gt;
  *   ...
@@ -87,7 +87,7 @@
  * </pre></tt>
  *
  * @author <a href="mailto:bh22351@i-one.at">Bernhard Huber</a>
- * @version CVS $Id: EncodeURLTransformer.java,v 1.8 2004/06/17 14:55:24 cziegeler Exp $
+ * @version CVS $Id$
  */
 public class EncodeURLTransformer
   extends AbstractTransformer
@@ -266,7 +266,7 @@
 
                     String value = new_attributes.getValue(i);
 
-                    if (elementAttributeMatching.matchesElementAttribute(lname, attr_lname))
{
+                    if (elementAttributeMatching.matchesElementAttribute(lname, attr_lname,
value)) {
                         // don't use simply this.response.encodeURL(value)
                         // but be more smart about the url encoding
                         final String new_value = this.encodeURL(value);
@@ -322,7 +322,7 @@
      * </p>
      *
      * @author     <a href="mailto:bh22351@i-one.at">Bernhard Huber</a>
-     * @version    CVS $Id: EncodeURLTransformer.java,v 1.8 2004/06/17 14:55:24 cziegeler
Exp $
+     * @version    CVS $Id$
      */
     public class ElementAttributeMatching {
         /**
@@ -353,14 +353,15 @@
         /**
          * Return true iff element_name attr_name pair is not matched by exclude-name,
          * but is matched by include-name
-         *
          * @param  element_name
          * @param  attr_name
+         * @param value TODO
+         *
          * @return               boolean true iff value of attribute_name should get rewritten,
else
          *   false.
          */
-        public boolean matchesElementAttribute(String element_name, String attr_name) {
-            String element_attr_name = canonicalizeElementAttribute(element_name, attr_name);
+        public boolean matchesElementAttribute(String element_name, String attr_name, String
value) {
+            String element_attr_name = canonicalizeElementAttribute(element_name, attr_name,
value);
 
             if (excludeNameRE != null && includeNameRE != null) {
                 return !matchesExcludesElementAttribute(element_attr_name) &&
@@ -377,13 +378,14 @@
          *   String concatenated <code>element name + "/@" + attribute name</code>
          *   is matched against the include and excluding patterns.
          * </p>
-         *
          * @param  element_name  Description of Parameter
          * @param  attr_name     Description of Parameter
+         * @param value The value
+         *
          * @return               Description of the Returned Value
          */
-        private String canonicalizeElementAttribute(String element_name, String attr_name)
{
-            return element_name + "/@" + attr_name;
+        private String canonicalizeElementAttribute(String element_name, String attr_name,
String value) {
+            return element_name + "/@" + attr_name + "=" + value;
         }
 
 

Mime
View raw message