// 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>"));
  }
 public void doError(
     HttpServletRequest request,
     HttpServletResponse response,
     Map<String, Object> theMap,
     String s,
     String message,
     Exception e)
     throws java.io.IOException {
   if (e != null) {
     M_log.error(e.getLocalizedMessage(), e);
   }
   theMap.put("/message_response/statusinfo/codemajor", "Fail");
   theMap.put("/message_response/statusinfo/severity", "Error");
   String msg = rb.getString(s) + ": " + message;
   M_log.info(msg);
   theMap.put(
       "/message_response/statusinfo/description", FormattedText.escapeHtmlFormattedText(msg));
   String theXml = XMLMap.getXML(theMap, true);
   PrintWriter out = response.getWriter();
   out.println(theXml);
   M_log.info("doError=" + theXml);
 }
Example #3
0
 /** Escape HTML-formatted text in preparation to include it in an HTML document. */
 public static String escapeHtmlFormattedText(String value) {
   return FormattedText.escapeHtmlFormattedText(value);
 }