Ejemplo n.º 1
0
  // KNL-526 - testing that targets are not destroyed or replaced
  public void testTargetNotOverridden() {
    // method 1 - processAnchor (kills all A attribs and only works on the first part of the tag
    assertEquals(
        "<a  href=\"other.html\" target=\"_blank\">",
        FormattedText.processAnchor("<a href=\"other.html\">"));
    assertEquals(
        "<a  href=\"other.html\" target=\"_blank\">",
        FormattedText.processAnchor("<a target=\"_blank\" href=\"other.html\">"));

    assertEquals(
        "<a  href=\"other.html\" target=\"_AZ\">",
        FormattedText.processAnchor("<a href=\"other.html\" target=\"_AZ\">"));
    // destroys other attributes though...
    assertEquals(
        "<a  href=\"other.html\" target=\"_AZ\">",
        FormattedText.processAnchor("<a href=\"other.html\" target=\"_AZ\" class=\"azeckoski\">"));

    // method 2 - escapeHtmlFormattedText (saves other A attribs)
    assertEquals(
        "<a href=\"other.html\" target=\"_blank\">link</a>",
        FormattedText.escapeHtmlFormattedText("<a href=\"other.html\">link</a>"));
    assertEquals(
        "<a href=\"other.html\" class=\"azeckoski\" target=\"_blank\">link</a>",
        FormattedText.escapeHtmlFormattedText(
            "<a href=\"other.html\" class=\"azeckoski\">link</a>"));
    assertEquals(
        "<b>simple</b><b class=\"AZ\">bold</b>",
        FormattedText.escapeHtmlFormattedText("<b>simple</b><b class=\"AZ\">bold</b>"));

    assertEquals(
        "<a href=\"other.html\" target=\"_AZ\">link</a>",
        FormattedText.escapeHtmlFormattedText("<a href=\"other.html\" target=\"_AZ\">link</a>"));
    assertEquals(
        "<a href=\"other.html\" target=\"_AZ\" class=\"azeckoski\">link</a>",
        FormattedText.escapeHtmlFormattedText(
            "<a href=\"other.html\" target=\"_AZ\" class=\"azeckoski\">link</a>"));

    assertEquals(
        "<a href=\"other.html\" class=\"azeckoski\" target=\"_blank\">link</a><a href=\"other.html\" target=\"_AZ\" class=\"azeckoski\">link</a>",
        FormattedText.escapeHtmlFormattedText(
            "<a href=\"other.html\" class=\"azeckoski\">link</a><a href=\"other.html\" target=\"_AZ\" class=\"azeckoski\">link</a>"));
    assertEquals(
        "<b>simple</b><b class=\"AZ\">bold</b><a href=\"other.html\" class=\"azeckoski\" target=\"_blank\">link</a><a href=\"other.html\" target=\"_AZ\" class=\"azeckoski\">link</a>",
        FormattedText.escapeHtmlFormattedText(
            "<b>simple</b><b class=\"AZ\">bold</b><a href=\"other.html\" class=\"azeckoski\">link</a><a href=\"other.html\" target=\"_AZ\" class=\"azeckoski\">link</a>"));
  }
Ejemplo n.º 2
0
 public void testProcessAnchor() {
   // Check we add the target attribute
   assertEquals(
       "<a  href=\"http://sakaiproject.org/\" target=\"_blank\">",
       FormattedText.processAnchor("<a href=\"http://sakaiproject.org/\">"));
 }
Ejemplo n.º 3
0
 public void testProcessAnchorName() {
   assertEquals(
       "<a  href=\"#anchor\" target=\"_blank\">",
       FormattedText.processAnchor("<a href=\"#anchor\">"));
 }
Ejemplo n.º 4
0
 public void testProcessAnchorMailto() {
   assertEquals(
       "<a  href=\"mailto:[email protected]\" target=\"_blank\">",
       FormattedText.processAnchor("<a href=\"mailto:[email protected]\">"));
 }
Ejemplo n.º 5
0
 public void testProcessAnchorRelative() {
   // Check we add the target attribute
   assertEquals(
       "<a  href=\"other.html\" target=\"_blank\">",
       FormattedText.processAnchor("<a href=\"other.html\">"));
 }