Author: julien_viet
Date: 2010-07-12 18:30:03 -0400 (Mon, 12 Jul 2010)
New Revision: 3626
Modified:
portal/trunk/component/web/src/main/java/org/exoplatform/services/html/refs/CharRefs.java
portal/trunk/component/web/src/main/java/org/exoplatform/services/html/refs/RefsDecoder.java
portal/trunk/component/web/src/main/java/org/exoplatform/upload/RequestStreamReader.java
Log:
hopefully finish to fix this mess
Modified:
portal/trunk/component/web/src/main/java/org/exoplatform/services/html/refs/CharRefs.java
===================================================================
---
portal/trunk/component/web/src/main/java/org/exoplatform/services/html/refs/CharRefs.java 2010-07-12
22:27:53 UTC (rev 3625)
+++
portal/trunk/component/web/src/main/java/org/exoplatform/services/html/refs/CharRefs.java 2010-07-12
22:30:03 UTC (rev 3626)
@@ -1,27 +1,22 @@
-/**
+/*
* Copyright (C) 2009 eXo Platform SAS.
- *
+ *
* This is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
- *
+ *
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
- *
+ *
* You should have received a copy of the GNU Lesser General Public
* License along with this software; if not, write to the Free
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
*/
-//HTMLParser Library $Name: v1_5 $ - A java-based parser for HTML
-//http://sourceforge.org/projects/htmlparser
-//Copyright (C) 2004 Derrick Oswald
-//Copyright (C) 2006 eXo Platform SARL
-
//Revision Control Information
//$Source: /cvsroot/htmlparser/htmlparser/src/org/htmlparser/util/Translate.java,v $
Modified:
portal/trunk/component/web/src/main/java/org/exoplatform/services/html/refs/RefsDecoder.java
===================================================================
---
portal/trunk/component/web/src/main/java/org/exoplatform/services/html/refs/RefsDecoder.java 2010-07-12
22:27:53 UTC (rev 3625)
+++
portal/trunk/component/web/src/main/java/org/exoplatform/services/html/refs/RefsDecoder.java 2010-07-12
22:30:03 UTC (rev 3626)
@@ -21,6 +21,8 @@
import org.exoplatform.services.chars.CharsUtil;
+import java.util.Comparator;
+
/**
* Author : Nhu Dinh Thuan
* nhudinhthuan(a)yahoo.com
@@ -29,6 +31,16 @@
public class RefsDecoder
{
+ private static final CharRefs charRefs = new CharRefs();
+
+ static Comparator<CharRef> comparator = new Comparator<CharRef>()
+ {
+ public int compare(CharRef o1, CharRef o2)
+ {
+ return o1.getName().compareTo(o2.getName());
+ }
+ };
+
public String decode(String text)
{
return new String(decodeChars(text.toCharArray()));
@@ -41,9 +53,8 @@
private char[] decodeChars(char[] chars)
{
- CharRefs charRefs = DecodeService.DECODE_CHARS_REF.getRef();
if (!charRefs.isSorted())
- charRefs.sort(DecodeService.comparator);
+ charRefs.sort(comparator);
int index = CharsUtil.indexOf(chars, '&', 0);
if (index < 0 || CharsUtil.indexOf(chars, ';', index) < 0)
return chars;
@@ -79,7 +90,7 @@
{
if (Character.isLetter(ckey[0]))
{
- CharRef item = charRefs.searchByName(new String(ckey),
DecodeService.comparator);
+ CharRef item = charRefs.searchByName(new String(ckey), comparator);
if (item != null)
{
decode.append((char)item.getValue());
Modified:
portal/trunk/component/web/src/main/java/org/exoplatform/upload/RequestStreamReader.java
===================================================================
---
portal/trunk/component/web/src/main/java/org/exoplatform/upload/RequestStreamReader.java 2010-07-12
22:27:53 UTC (rev 3625)
+++
portal/trunk/component/web/src/main/java/org/exoplatform/upload/RequestStreamReader.java 2010-07-12
22:30:03 UTC (rev 3626)
@@ -19,7 +19,7 @@
package org.exoplatform.upload;
-import org.exoplatform.upload.toremove.RefsDecoder;
+import org.exoplatform.services.html.refs.RefsDecoder;
import java.io.ByteArrayOutputStream;
import java.io.IOException;