From e6741360127c13ba4cc5012f23f70c10b247131c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Svenn=20Gjet=C3=B8?= Date: Tue, 28 May 2013 16:52:20 +0200 Subject: [PATCH] DS-1164 ensuring UTF-8 encoding is enforced National characters is important! --- .../wing/element/SimpleHTMLFragment.java | 50 +++++++++---------- 1 file changed, 25 insertions(+), 25 deletions(-) diff --git a/dspace-xmlui/src/main/java/org/dspace/app/xmlui/wing/element/SimpleHTMLFragment.java b/dspace-xmlui/src/main/java/org/dspace/app/xmlui/wing/element/SimpleHTMLFragment.java index 89cb5bb97180..d32bdd4c744e 100644 --- a/dspace-xmlui/src/main/java/org/dspace/app/xmlui/wing/element/SimpleHTMLFragment.java +++ b/dspace-xmlui/src/main/java/org/dspace/app/xmlui/wing/element/SimpleHTMLFragment.java @@ -35,18 +35,18 @@ /** * This class represents data that is translated from simple HTML or plain text. - * + * * This class represents a simple HTML fragment. It allows for user-supplied * HTML to be translated on the fly into DRI. - * + * * At the present time it only supports the following tags: h1, h2, h3, h4, h5, * p, a, b, i, u, ol, li and img. Each are translated into their DRI equivalents, note * the "h" tags are translated into a paragraph of rend=heading. - * - * If the linkbreaks flag is set then line breaks are treated as paragraphs. This - * allows plain text files to also be included and they will be mapped into DRI as + * + * If the linkbreaks flag is set then line breaks are treated as paragraphs. This + * allows plain text files to also be included and they will be mapped into DRI as * well. - * + * * @author Scott Phillips * @author Jay Paz */ @@ -61,7 +61,7 @@ public class SimpleHTMLFragment extends AbstractWingElement { /** * Construct a fragment object for translating into DRI. - * + * * @param context * (Required) The context this element is contained in, such as * where to route SAX events and what i18n catalogue to use. @@ -81,7 +81,7 @@ protected SimpleHTMLFragment(WingContext context, boolean blankLines, /** * Translate this element into SAX - * + * * @param contentHandler * (Required) The registered contentHandler where SAX events * should be routed too. @@ -99,7 +99,7 @@ public void toSAX(ContentHandler contentHandler, String xml = "" + fragment + ""; ByteArrayInputStream inputStream = new ByteArrayInputStream(xml - .getBytes()); + .getBytes("UTF-8")); SAXBuilder builder = new SAXBuilder(); Document document = builder.build(inputStream); @@ -141,10 +141,10 @@ public void toSAX(ContentHandler contentHandler, /** * Remove the given content from the Element. - * + * * If the content is an element then render it as text and include it's * children in the parent. - * + * * @param content * The DOM Content to be removed. */ @@ -202,10 +202,10 @@ private void removeContent(Content content) { /** * Wrap the given set of contents into a paragraph and place it at the * supplied index. - * + * * This method will also check for trivial paragraphs, i.e. those that * contain nothing but white space. If they are found then they are removed. - * + * * @param parent * The parent element to attach the wrapped paragraph, too. * @param index @@ -265,7 +265,7 @@ private boolean paragraphWrap(Element parent, int index, /** * Ensure that the given element only has the supplied attributes. Also * remove any possible namespaces on the attributes. - * + * * @param element * The element to be checked. * @param names @@ -291,7 +291,7 @@ private void limitAttributes(Element element, String... names) { /** * Move the old attribute to a new attribute. - * + * * @param element * The element * @param oldName @@ -309,15 +309,15 @@ private void moveAttribute(Element element, String oldName, String newName) { /** * Translate the given HTML fragment into a DRI document. - * + * * The translation is broken up into two steps, 1) recurse through all * elements and either translate them into their DRI equivalents or remove * them from the document. - * + * * The second step, 2) is to iterate over all top level elements and ensure * that they only consist of paragraphs. Also at this stage if linkBreaks is * true then \n are treated as paragraph breaks. - * + * * @param parent * The Element to translate into DRI. */ @@ -454,7 +454,7 @@ else if ("hi".equals(name)) { List removed = new ArrayList(); for (int i = 0; i < parent.getContentSize(); i++) { Content current = parent.getContent(i); - + if ((current instanceof Element) && ("p".equals(((Element) current).getName()))) { // A paragraph is being open, combine anything up to this @@ -517,15 +517,15 @@ else if ("hi".equals(name)) { * from the originating HTML fragment, 2) to get around a JDOM bug where it * can not output SAX events for just a document fragment. Since it only * works with documents this class was created to filter out the events. - * + * * As far as I can tell, the first time the bug was identified is in the * following email, point #1: - * + * * http://www.servlets.com/archive/servlet/ReadMsg?msgId=491592&listName=jdom-interest - * + * * I, Scott Phillips, checked the JDOM CVS source tree on 3-8-2006 and the * bug had not been patch at that time. - * + * */ public static class SAXFilter implements ContentHandler, LexicalHandler { @@ -546,7 +546,7 @@ public SAXFilter(ContentHandler contentHandler, /** * Create the qName for the element with the given localName and * namespace prefix. - * + * * @param localName * (Required) The element's local name. * @return @@ -650,4 +650,4 @@ public void comment(char[] ch, int start, int length) } } } - +