You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@roller.apache.org by sn...@apache.org on 2006/11/12 00:41:16 UTC

svn commit: r473829 - /incubator/roller/trunk/src/org/apache/roller/pojos/WeblogEntryData.java

Author: snoopdave
Date: Sat Nov 11 15:41:14 2006
New Revision: 473829

URL: http://svn.apache.org/viewvc?view=rev&rev=473829
Log:
Fix for ROL-1293: "Regression: non-alphanumics not stripped from anchors"

Modified:
    incubator/roller/trunk/src/org/apache/roller/pojos/WeblogEntryData.java

Modified: incubator/roller/trunk/src/org/apache/roller/pojos/WeblogEntryData.java
URL: http://svn.apache.org/viewvc/incubator/roller/trunk/src/org/apache/roller/pojos/WeblogEntryData.java?view=diff&rev=473829&r1=473828&r2=473829
==============================================================================
--- incubator/roller/trunk/src/org/apache/roller/pojos/WeblogEntryData.java (original)
+++ incubator/roller/trunk/src/org/apache/roller/pojos/WeblogEntryData.java Sat Nov 11 15:41:14 2006
@@ -1092,19 +1092,17 @@
     /** Create anchor for weblog entry, based on title or text */
     public String createAnchorBase() {
         
-        // Use title or text for base anchor
-        String base = getTitle();
-        if (StringUtils.isEmpty(base.trim())) {
-            base = Utilities.replaceNonAlphanumeric(base, ' ');
-            if (StringUtils.isEmpty(base.trim())) {
-                base = getText();
-                if (base != null) {
-                    base = Utilities.replaceNonAlphanumeric(base, ' ');
-                }
-            }
+        // Use title (minus non-alphanumeric characters)
+        String base = null;
+        if (!StringUtils.isEmpty(getTitle())) {
+            base = Utilities.replaceNonAlphanumeric(getTitle(), ' ').trim();    
         }
-
-        if (!StringUtils.isEmpty(base.trim())) {
+        // If we still have no base, then try text (minus non-alphanumerics)
+        if (StringUtils.isEmpty(base) && !StringUtils.isEmpty(getText())) {
+            base = Utilities.replaceNonAlphanumeric(getText(), ' ').trim();  
+        }
+        
+        if (!StringUtils.isEmpty(base)) {
             
             // Use only the first 4 words
             StringTokenizer toker = new StringTokenizer(base);