/** * Strips string of HTML and returns plain text. * * @param s * @return */ public static String stripHtml(String s) { return FormattedText.convertFormattedTextToPlaintext(s); }
/** * Escape plaintext for display inside a plain textarea. * @deprecated this is a passthrough for {@link FormattedText#escapeHtml(String, boolean)} so use that instead */ public static String escapeHtmlTextarea(String value) { return FormattedText.escapeHtml(value, false); }
/** * Escape HTML-formatted text in preparation to include it in an HTML document. * * @param value * The string to escape. * @return value escaped for HTML. * @deprecated this is a passthrough for {@link FormattedText#escapeHtmlFormattedText(String)} so use that instead */ public static String escapeHtmlFormattedText(String value) { return FormattedText.escapeHtmlFormattedText(value); }
/** * @param formattedText The formatted text to convert to plain text and then to trim * @param maxNumOfChars The maximum number of characters for the trimmed text. * @return Ellipse A String to represent the ending pattern of the trimmed text */ public String doPlainTextAndLimit(String formattedText, int maxNumOfChars, String ellipse) { formattedText = StringUtils.trimToNull(formattedText); if(formattedText == null || formattedText.equalsIgnoreCase("<br/>") || formattedText.equalsIgnoreCase("<br>")|| formattedText.equals(" ") || FormattedText.escapeHtml(formattedText,false).equals("<br type="_moz" />")){ return ""; } StringBuilder sb = new StringBuilder(); String text = FormattedText.convertFormattedTextToPlaintext(formattedText); if(maxNumOfChars>text.length()){ maxNumOfChars=text.length(); } String trimmedText=text.substring(0, maxNumOfChars); sb.setLength(0); sb.append(trimmedText).append(ellipse); return Validator.escapeHtml(sb.toString()); } }
m_body = FormattedText.decodeFormattedTextAttribute(el, "body"); if (m_body != null) m_body = FormattedText.convertPlaintextToFormattedText(m_body);
m_timeLastModified = getTimeObject(el.getAttribute("lastmod")); m_instructions = FormattedText.decodeFormattedTextAttribute(el, "instructions"); m_instructions = FormattedText.convertPlaintextToFormattedText(m_instructions); if (element.getTagName().equals("instructions-formatted")) m_instructions = FormattedText.convertOldFormattedText(m_instructions);
/** * Get the formatted body (either html or plain-text converted to html), as a string. * * @return The formatted body as a string. */ public String getFormattedBody() { if ( getHtmlBody() != null && getHtmlBody().length() > 0 ) return m_html_body; else return Web.encodeUrlsAsHtml( FormattedText.convertPlaintextToFormattedText(m_body) ); } // getHtmlBody
/** * Processes HTML and escapes evils tags like <script>, also converts newlines to proper HTML breaks. * @param s * @return */ public static String processHtml(String s){ return FormattedText.processFormattedText(s, new StringBuilder(), true, false); }
/** * This is to mimic the FormattedText.decodeFormattedTextAttribute but use SAX serialization instead * @return */ protected String formattedTextDecodeFormattedTextAttribute(Attributes attributes, String baseAttributeName) { String ret; // first check if an HTML-encoded attribute exists, for example "foo-html", and use it if available ret = StringUtils.trimToNull(xmlDecodeAttribute(attributes, baseAttributeName + "-html")); if (ret != null) return ret; // next try the older kind of formatted text like "foo-formatted", and convert it if found ret = StringUtils.trimToNull(xmlDecodeAttribute(attributes, baseAttributeName + "-formatted")); ret = FormattedText.convertOldFormattedText(ret); if (ret != null) return ret; // next try just a plaintext attribute and convert the plaintext to formatted text if found // convert from old plaintext instructions to new formatted text instruction ret = xmlDecodeAttribute(attributes, baseAttributeName); ret = FormattedText.convertPlaintextToFormattedText(ret); return ret; }
/** * Escapes the given HTML-formatted text for editing within the WYSIWYG editor. All HTML meta-characters in the string (such as amperstand, less-than, etc), will be escaped. * * @param value * The formatted text to escape * @return The string to use as the value of the formatted textarea widget * @deprecated this is a passthrough for {@link FormattedText#escapeHtmlFormattedTextarea(String)} so use that instead */ public static String escapeHtmlFormattedTextarea(String value) { return FormattedText.escapeHtmlFormattedTextarea(value); }
FormattedText.encodeFormattedTextAttribute(message, "body", getBody());
m_hideDueDate = getBool(el.getAttribute("hideduedate")); m_submittedText = FormattedText.decodeFormattedTextAttribute(el, "submittedtext"); m_feedbackComment = FormattedText.decodeFormattedTextAttribute(el, "feedbackcomment"); m_feedbackText = FormattedText.decodeFormattedTextAttribute(el, "feedbacktext");
m_body = FormattedText.decodeFormattedTextAttribute(el, "body"); if (m_body != null) m_body = FormattedText.convertPlaintextToFormattedText(m_body);
if (m_body != null) m_body = FormattedText.convertPlaintextToFormattedText(m_body);
/** * Processes HTML and escapes evils tags like <script>, also converts newlines to proper HTML breaks. * @param s * @return */ public static String processHtml(String s){ return FormattedText.processFormattedText(s, new StringBuilder(), true, false); }
siteTitle = FormattedText.escapeHtmlFormattedTextarea(siteTitle); subject = FormattedText.escapeHtmlFormattedTextarea(subject); resourceName = FormattedText.escapeHtmlFormattedTextarea(resourceName); description = FormattedText.escapeHtmlFormattedTextarea(description); dropboxTitle = FormattedText.escapeHtmlFormattedTextarea(dropboxTitle); blankLine = "\n</p><p>\n"; newLine = "<br/>\n";
FormattedText.encodeFormattedTextAttribute(message, "body", getBody());
/** * Strips string of HTML and returns plain text. * * @param s * @return */ public static String stripHtml(String s) { return FormattedText.convertFormattedTextToPlaintext(s); }
@Override public String htmlSpecialChars(String str) { return FormattedText.escapeHtml(str, false); }
m_body = FormattedText.decodeFormattedTextAttribute(el, "body"); if (m_body != null) m_body = FormattedText.convertPlaintextToFormattedText(m_body);