Author: channa
Date: Wed Jul 16 03:03:32 2008
New Revision: 19380
URL: http://wso2.org/svn/browse/wso2?view=rev&revision=19380

Log:
Corrected comment deletion issue, which was caused by a newline appended by the 
sanitization function. MASHUP-959. Also refined comment wrapping MASHUP-469.

Modified:
   trunk/mashup/java/modules/core/src/org/wso2/mashup/utils/MashupUtils.java
   trunk/mashup/java/modules/www/activity.jsp
   trunk/mashup/java/modules/www/index.jsp
   trunk/mashup/java/modules/www/mashup.jsp

Modified: 
trunk/mashup/java/modules/core/src/org/wso2/mashup/utils/MashupUtils.java
URL: 
http://wso2.org/svn/browse/wso2/trunk/mashup/java/modules/core/src/org/wso2/mashup/utils/MashupUtils.java?rev=19380&r1=19379&r2=19380&view=diff
==============================================================================
--- trunk/mashup/java/modules/core/src/org/wso2/mashup/utils/MashupUtils.java   
(original)
+++ trunk/mashup/java/modules/core/src/org/wso2/mashup/utils/MashupUtils.java   
Wed Jul 16 03:03:32 2008
@@ -1420,6 +1420,11 @@
             AntiSamy as = new AntiSamy();
             CleanResults cr = as.scan(htmlContent, policy);
             cleanHtml = cr.getCleanHTML();
+
+            // If the sanitization has added a newline, remove it.
+            if (cleanHtml.endsWith("\n") && !htmlContent.endsWith("\n")) {
+                cleanHtml = cleanHtml.substring(0, (cleanHtml.length() - 1));
+            }
         } catch (PolicyException e) {
             log.error("HTML Sanitization policy error", e);
         } catch (ScanException e) {
@@ -1515,7 +1520,7 @@
         if (sourceText.length() > maxUnbroken) {
             processedString = new StringBuilder();
             // Breaking up string to identify longest unbroken segments, for 
space insertion.
-            String [] segments = sourceText.split("\\s");
+            String [] segments = sourceText.split(" ");
 
             // Process each segment separately.
             for (int i = 0; i < segments.length; i++) {
@@ -1532,7 +1537,9 @@
                 processedString.append(segments[i]);
 
                 // Restoring spaces lost in split operation.
-                processedString.append(" ");
+                if (i < (segments.length - 1)) {
+                    processedString.append(" ");
+                }
             }
 
             // If no insertions were actually needed, return the original 
string.

Modified: trunk/mashup/java/modules/www/activity.jsp
URL: 
http://wso2.org/svn/browse/wso2/trunk/mashup/java/modules/www/activity.jsp?rev=19380&r1=19379&r2=19380&view=diff
==============================================================================
--- trunk/mashup/java/modules/www/activity.jsp  (original)
+++ trunk/mashup/java/modules/www/activity.jsp  Wed Jul 16 03:03:32 2008
@@ -108,7 +108,7 @@
                         .getContentString()%>
                 </a>
                     <% } else if (action.equals("commented")) { %>
-                    <span class="inline-comment">"<%= 
MashupUtils.makeWrappable(result.getContentString(), 100) %>"</span>
+                    <span class="inline-comment">"<%= 
MashupUtils.makeWrappable(result.getContentString(), 60) %>"</span>
                     <% } %>
                 </td>
             </tr>

Modified: trunk/mashup/java/modules/www/index.jsp
URL: 
http://wso2.org/svn/browse/wso2/trunk/mashup/java/modules/www/index.jsp?rev=19380&r1=19379&r2=19380&view=diff
==============================================================================
--- trunk/mashup/java/modules/www/index.jsp     (original)
+++ trunk/mashup/java/modules/www/index.jsp     Wed Jul 16 03:03:32 2008
@@ -294,7 +294,7 @@
                     
href="search.jsp?query=mashups&for=<%=result.getContentString()%>&tags=true"><%=result
                     .getContentString()%></a>
         <% } else if (action.equals("commented")) { %>
-        <span class="inline-comment">"<%= 
MashupUtils.makeWrappable(result.getContentString(), 100) %>"</span>
+        <span class="inline-comment">"<%= 
MashupUtils.makeWrappable(result.getContentString(), 60) %>"</span>
         <% } %>
     </td>
 </tr>

Modified: trunk/mashup/java/modules/www/mashup.jsp
URL: 
http://wso2.org/svn/browse/wso2/trunk/mashup/java/modules/www/mashup.jsp?rev=19380&r1=19379&r2=19380&view=diff
==============================================================================
--- trunk/mashup/java/modules/www/mashup.jsp    (original)
+++ trunk/mashup/java/modules/www/mashup.jsp    Wed Jul 16 03:03:32 2008
@@ -635,7 +635,7 @@
                         .getFullName(request, commenter) %></a> 
(<%=commenter%>)
                 </td>
                 <td class="right" colspan="2">
-                    <%= MashupUtils.makeWrappable(text, 100) %>
+                    <%= MashupUtils.makeWrappable(text, 60) %>
                     <%
                         if (author.equals(currentUser) || 
commenter.equals(currentUser) || RegistryUtils.isAdminRole(userRegistry)) {
                             String shortCommentText;

_______________________________________________
Mashup-dev mailing list
[email protected]
http://wso2.org/cgi-bin/mailman/listinfo/mashup-dev

Reply via email to