Ejemplo n.º 1
0
  @Dynamic("editor")
  public static Result publish() {
    Form<utils.Forms.PublicationBinder> bindedForm =
        form(utils.Forms.PublicationBinder.class).bindFromRequest();

    Long l = bindedForm.get().location;
    Long i = bindedForm.get().interest;

    if (i != null && l != null) {
      final User u = Mupi.getLocalUser(session());
      final models.Profile p = u.profile;

      String safeBody =
          Jsoup.clean(
              bindedForm.get().body,
              Whitelist.basicWithImages()
                  .addEnforcedAttribute("a", "target", "_blank")
                  .addTags("h1", "h2"));

      Publication.create(
          p,
          models.Location.find.byId(l),
          models.Interest.find.byId(i),
          PubType.get(bindedForm.get().pub_typ),
          safeBody);
    }
    return selectFeed(getLocalInterest(), getLocalLocation());
  }
Ejemplo n.º 2
0
 @Test
 public void basicWithImagesTest() {
   String h =
       "<div><p><img src='http://example.com/' alt=Image></p><p><img src='ftp://ftp.example.com'></p></div>";
   String cleanHtml = Jsoup.clean(h, Whitelist.basicWithImages());
   assertEquals(
       "<p><img src=\"http://example.com/\" alt=\"Image\" /></p><p><img /></p>",
       TextUtil.stripNewlines(cleanHtml));
 }
Ejemplo n.º 3
0
 @Test
 public void testHandlesEmptyAttributes() {
   String h = "<img alt=\"\" src= unknown=''>";
   String cleanHtml = Jsoup.clean(h, Whitelist.basicWithImages());
   assertEquals("<img alt=\"\" />", cleanHtml);
 }