Patch - SocialBookmarksDecorator

View: New views
3 Messages — Rating Filter:   Alert me  

Patch - SocialBookmarksDecorator

by Wyatt-13 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

I found that the title was not being properly escaped in the link.

Index: src/net/sourceforge/pebble/decorator/SocialBookmarksDecorator.java
===================================================================
--- src/net/sourceforge/pebble/decorator/SocialBookmarksDecorator.java (revision 492)
+++ src/net/sourceforge/pebble/decorator/SocialBookmarksDecorator.java (working copy)
@@ -5,6 +5,8 @@
 import net.sourceforge.pebble.domain.StaticPage;
 import net.sourceforge.pebble.api.decorator.ContentDecoratorContext;
 
+import java.io.UnsupportedEncodingException;
+import java.net.URLEncoder;
 import java.util.ResourceBundle;
 
 /**
@@ -102,7 +104,13 @@
  BlogEntry blogEntry) {
  StringBuffer buf = new StringBuffer();
  String permLink = blogEntry.getPermalink();
- String title = blogEntry.getTitle();
+ String title = "";
+ try {
+ title = URLEncoder.encode(blogEntry.getTitle(), "UTF-8");
+ }
+ catch(UnsupportedEncodingException e) {
+ title = blogEntry.getTitle();
+ }
  buf.append("<div class=\"tags\"><span>");
  buf.append(bundle.getString("common.bookmarks"));
  buf.append(" : </span> ");

------------------------------------------------------------------------------
Enter the BlackBerry Developer Challenge  
This is your chance to win up to $100,000 in prizes! For a limited time,
vendors submitting new applications to BlackBerry App World(TM) will have
the opportunity to enter the BlackBerry Developer Challenge. See full prize  
details at: http://p.sf.net/sfu/Challenge
_______________________________________________
Pebble-user mailing list
Pebble-user@...
https://lists.sourceforge.net/lists/listinfo/pebble-user

Re: Patch - SocialBookmarksDecorator

by Olaf Kock-3 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Wyatt schrieb:
> I found that the title was not being properly escaped in the link.

Thanks a lot, committed,

Olaf

------------------------------------------------------------------------------
Enter the BlackBerry Developer Challenge  
This is your chance to win up to $100,000 in prizes! For a limited time,
vendors submitting new applications to BlackBerry App World(TM) will have
the opportunity to enter the BlackBerry Developer Challenge. See full prize  
details at: http://p.sf.net/sfu/Challenge
_______________________________________________
Pebble-user mailing list
Pebble-user@...
https://lists.sourceforge.net/lists/listinfo/pebble-user

Re: Patch - SocialBookmarksDecorator

by Wyatt-13 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi Olaf,

It looks like my fix for SocialBookmarksDecorator.java broke
SocialBookmarksDecoratorTest.java.  The attached patch fixes the test-case.

Cheers,
Wyatt


On 7/9/2009 5:06 PM, Olaf Kock wrote:

> Wyatt schrieb:
>> I found that the title was not being properly escaped in the link.
>
> Thanks a lot, committed,
>
> Olaf
>
> ------------------------------------------------------------------------------
> Enter the BlackBerry Developer Challenge
> This is your chance to win up to $100,000 in prizes! For a limited time,
> vendors submitting new applications to BlackBerry App World(TM) will have
> the opportunity to enter the BlackBerry Developer Challenge. See full prize
> details at: http://p.sf.net/sfu/Challenge
> _______________________________________________
> Pebble-user mailing list
> Pebble-user@...
> https://lists.sourceforge.net/lists/listinfo/pebble-user

Index: test/net/sourceforge/pebble/decorator/SocialBookmarksDecoratorTest.java
===================================================================
--- test/net/sourceforge/pebble/decorator/SocialBookmarksDecoratorTest.java (revision 492)
+++ test/net/sourceforge/pebble/decorator/SocialBookmarksDecoratorTest.java (working copy)
@@ -75,20 +75,19 @@
 
     StringBuffer bookmarks = new StringBuffer();
     bookmarks.append("<div class=\"tags\"><span>Social Bookmarks : </span> ");
-    bookmarks.append("<a href=\"http://slashdot.org/bookmark.pl?url=http://www.yourdomain.com/blog/1970/01/01/1.html&title=Bombastic Post Title\" target=\"_blank\" title=\"Add this post to Slash Dot\"><img src=\"common/images/slashdot.png\" alt=\"Add this post to Slashdot\" border=\"0\" /></a>    ");
- bookmarks.append("<a href=\"http://digg.com/submit?url=http://www.yourdomain.com/blog/1970/01/01/1.html&title=Bombastic Post Title\" target=\"_blank\" title=\"Digg this post\"><img src=\"common/images/digg.png\" alt=\"Add this post to Digg\" border=\"0\" /></a>    ");
- bookmarks.append("<a href=\"http://reddit.com/submit?url=http://www.yourdomain.com/blog/1970/01/01/1.html&title=Bombastic Post Title\" target=\"_blank\" title=\"Add this post to Reddit\"><img src=\"common/images/reddit.png\" alt=\"Add this post to Reddit\" border=\"0\" /></a>    ");
- bookmarks.append("<a href=\"http://del.icio.us/post?url=http://www.yourdomain.com/blog/1970/01/01/1.html&title=Bombastic Post Title\" target=\"_blank\" title=\"Save this post to Del.icio.us\"><img src=\"common/images/delicious.png\" alt=\"Add this post to Delicious\" border=\"0\" /></a>    ");
- bookmarks.append("<a href=\"http://www.stumbleupon.com/submit?url=http://www.yourdomain.com/blog/1970/01/01/1.html&title=Bombastic Post Title\" target=\"_blank\" title=\"Stumble this post\"><img src=\"common/images/stumbleupon.png\" alt=\"Add this post to Stumble it\" border=\"0\" /></a>    ");
- bookmarks.append("<a href=\"http://www.google.com/bookmarks/mark?op=edit&bkmk=http://www.yourdomain.com/blog/1970/01/01/1.html&title=Bombastic Post Title\" target=\"_blank\" title=\"Add this post to Google\"><img src=\"common/images/google.png\" alt=\"Add this post to Google\" border=\"0\" /></a>    ");
- bookmarks.append("<a href=\"http://technorati.com/faves?add=http://www.yourdomain.com/blog/1970/01/01/1.html\" target=\"_blank\" title=\"Add this post to Technorati\"><img src=\"common/images/technorati.png\" alt=\"Add this post to Technorati\" border=\"0\" /></a>    ");
- bookmarks.append("<a href=\"http://www.bloglines.com/sub/http://www.yourdomain.com/blog/1970/01/01/1.html\" target=\"_blank\" title=\"Add this post to Bloglines\"><img src=\"common/images/bloglines.png\" alt=\"Add this post to Bloglines\" border=\"0\" /></a>    ");
- bookmarks.append("<a href=\"http://www.facebook.com/share.php?u=http://www.yourdomain.com/blog/1970/01/01/1.html\" target=\"_blank\" title=\"Add this post to Facebook\"><img src=\"common/images/facebook.png\" alt=\"Add this post to Facebook\" border=\"0\" /></a>    ");
- bookmarks.append("<a href=\"http://www.furl.net/storeIt.jsp?u=http://www.yourdomain.com/blog/1970/01/01/1.html&t=Bombastic Post Title\" target=\"_blank\" title=\"Add this post to Furl\"><img src=\"common/images/furl.png\" alt=\"Add this post to Furl\" border=\"0\" /></a>    ");
- bookmarks.append("<a href=\"https://favorites.live.com/quickadd.aspx?mkt=en-us&url=http://www.yourdomain.com/blog/1970/01/01/1.html&title=Bombastic Post Title\" target=\"_blank\" title=\"Add this post to Windows Live\"><img src=\"common/images/windowslive.png\" alt=\"Add this post to Windows Live\" border=\"0\" /></a>    ");
- bookmarks.append("<a href=\"http://bookmarks.yahoo.com/toolbar/savebm?opener=tb&u=http://www.yourdomain.com/blog/1970/01/01/1.html&t=Bombastic Post Title\" target=\"_blank\" title=\"Add this post to Yahoo!\"><img src=\"common/images/yahoo.png\" alt=\"Add this post to Yahoo!\" border=\"0\" /></a>");
+    bookmarks.append("<a href=\"http://slashdot.org/bookmark.pl?url=http://www.yourdomain.com/blog/1970/01/01/1.html&title=Bombastic+Post+Title\" target=\"_blank\" title=\"Add this post to Slash Dot\"><img src=\"common/images/slashdot.png\" alt=\"Add this post to Slashdot\" border=\"0\" /></a>    ");
+    bookmarks.append("<a href=\"http://digg.com/submit?url=http://www.yourdomain.com/blog/1970/01/01/1.html&title=Bombastic+Post+Title\" target=\"_blank\" title=\"Digg this post\"><img src=\"common/images/digg.png\" alt=\"Add this post to Digg\" border=\"0\" /></a>    ");
+    bookmarks.append("<a href=\"http://reddit.com/submit?url=http://www.yourdomain.com/blog/1970/01/01/1.html&title=Bombastic+Post+Title\" target=\"_blank\" title=\"Add this post to Reddit\"><img src=\"common/images/reddit.png\" alt=\"Add this post to Reddit\" border=\"0\" /></a>    ");
+    bookmarks.append("<a href=\"http://del.icio.us/post?url=http://www.yourdomain.com/blog/1970/01/01/1.html&title=Bombastic+Post+Title\" target=\"_blank\" title=\"Save this post to Del.icio.us\"><img src=\"common/images/delicious.png\" alt=\"Add this post to Delicious\" border=\"0\" /></a>    ");
+    bookmarks.append("<a href=\"http://www.stumbleupon.com/submit?url=http://www.yourdomain.com/blog/1970/01/01/1.html&title=Bombastic+Post+Title\" target=\"_blank\" title=\"Stumble this post\"><img src=\"common/images/stumbleupon.png\" alt=\"Add this post to Stumble it\" border=\"0\" /></a>    ");
+    bookmarks.append("<a href=\"http://www.google.com/bookmarks/mark?op=edit&bkmk=http://www.yourdomain.com/blog/1970/01/01/1.html&title=Bombastic+Post+Title\" target=\"_blank\" title=\"Add this post to Google\"><img src=\"common/images/google.png\" alt=\"Add this post to Google\" border=\"0\" /></a>    ");
+    bookmarks.append("<a href=\"http://technorati.com/faves?add=http://www.yourdomain.com/blog/1970/01/01/1.html\" target=\"_blank\" title=\"Add this post to Technorati\"><img src=\"common/images/technorati.png\" alt=\"Add this post to Technorati\" border=\"0\" /></a>    ");
+    bookmarks.append("<a href=\"http://www.bloglines.com/sub/http://www.yourdomain.com/blog/1970/01/01/1.html\" target=\"_blank\" title=\"Add this post to Bloglines\"><img src=\"common/images/bloglines.png\" alt=\"Add this post to Bloglines\" border=\"0\" /></a>    ");
+    bookmarks.append("<a href=\"http://www.facebook.com/share.php?u=http://www.yourdomain.com/blog/1970/01/01/1.html\" target=\"_blank\" title=\"Add this post to Facebook\"><img src=\"common/images/facebook.png\" alt=\"Add this post to Facebook\" border=\"0\" /></a>    ");
+    bookmarks.append("<a href=\"http://www.furl.net/storeIt.jsp?u=http://www.yourdomain.com/blog/1970/01/01/1.html&t=Bombastic+Post+Title\" target=\"_blank\" title=\"Add this post to Furl\"><img src=\"common/images/furl.png\" alt=\"Add this post to Furl\" border=\"0\" /></a>    ");
+    bookmarks.append("<a href=\"https://favorites.live.com/quickadd.aspx?mkt=en-us&url=http://www.yourdomain.com/blog/1970/01/01/1.html&title=Bombastic+Post+Title\" target=\"_blank\" title=\"Add this post to Windows Live\"><img src=\"common/images/windowslive.png\" alt=\"Add this post to Windows Live\" border=\"0\" /></a>    ");
+    bookmarks.append("<a href=\"http://bookmarks.yahoo.com/toolbar/savebm?opener=tb&u=http://www.yourdomain.com/blog/1970/01/01/1.html&t=Bombastic+Post+Title\" target=\"_blank\" title=\"Add this post to Yahoo!\"><img src=\"common/images/yahoo.png\" alt=\"Add this post to Yahoo!\" border=\"0\" /></a>");
     bookmarks.append("</div>");
-
  assertEquals("Excerpt - here is some text" + bookmarks, blogEntry.getExcerpt());
     assertEquals("Body - here is some text" + bookmarks, blogEntry.getBody());
   }

------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
trial. Simplify your report design, integration and deployment - and focus on
what you do best, core application coding. Discover what's new with
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
Pebble-user mailing list
Pebble-user@...
https://lists.sourceforge.net/lists/listinfo/pebble-user