[exo-jcr-commits] exo-jcr SVN: r2794 - in jcr/trunk/exo.jcr.component.webdav/src: test/java/org/exoplatform/services/jcr/webdav/command and 1 other directory.
do-not-reply at jboss.org
do-not-reply at jboss.org
Thu Jul 15 09:36:39 EDT 2010
Author: dkatayev
Date: 2010-07-15 09:36:39 -0400 (Thu, 15 Jul 2010)
New Revision: 2794
Modified:
jcr/trunk/exo.jcr.component.webdav/src/main/java/org/exoplatform/services/jcr/webdav/xml/PropertyWriteUtil.java
jcr/trunk/exo.jcr.component.webdav/src/test/java/org/exoplatform/services/jcr/webdav/command/TestPropFind.java
Log:
EXOJCR-857 Only special characters in displayname property are decoded.
Modified: jcr/trunk/exo.jcr.component.webdav/src/main/java/org/exoplatform/services/jcr/webdav/xml/PropertyWriteUtil.java
===================================================================
--- jcr/trunk/exo.jcr.component.webdav/src/main/java/org/exoplatform/services/jcr/webdav/xml/PropertyWriteUtil.java 2010-07-15 13:28:41 UTC (rev 2793)
+++ jcr/trunk/exo.jcr.component.webdav/src/main/java/org/exoplatform/services/jcr/webdav/xml/PropertyWriteUtil.java 2010-07-15 13:36:39 UTC (rev 2794)
@@ -26,6 +26,8 @@
import java.util.Iterator;
import java.util.Map;
import java.util.Set;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
import javax.xml.stream.XMLStreamException;
import javax.xml.stream.XMLStreamWriter;
@@ -133,15 +135,21 @@
}
writeAttributes(xmlStreamWriter, prop);
-
- try
+
+ if (prop.getName().getLocalPart().equals("displayname") && containsEncodedChar(prop.getValue()))
{
- xmlStreamWriter.writeCharacters(URLDecoder.decode(prop.getValue(), "UTF-8"));
+ try
+ {
+ xmlStreamWriter.writeCharacters(URLDecoder.decode(prop.getValue(), "UTF-8"));
+ }
+ catch (UnsupportedEncodingException e)
+ {
+ e.printStackTrace();
+ }
+ } else {
+ xmlStreamWriter.writeCharacters(prop.getValue());
}
- catch (UnsupportedEncodingException e)
- {
- e.printStackTrace();
- }
+
xmlStreamWriter.writeEndElement();
}
}
@@ -165,5 +173,17 @@
xmlStreamWriter.writeAttribute(attrName, attrValue);
}
}
+
+ /**
+ * Checks if string contains encoded characters like %2f.
+ * @param str string to check.
+ * @return <code>true</code> if string contains encoded characters, otherwise returns <code>false</code>
+ */
+ private static boolean containsEncodedChar(String str){
+ Pattern p = Pattern.compile("%[0-9a-fA-F]{2}");
+ Matcher matcher = p.matcher(str);
+ return matcher.find();
+
+ }
}
Modified: jcr/trunk/exo.jcr.component.webdav/src/test/java/org/exoplatform/services/jcr/webdav/command/TestPropFind.java
===================================================================
--- jcr/trunk/exo.jcr.component.webdav/src/test/java/org/exoplatform/services/jcr/webdav/command/TestPropFind.java 2010-07-15 13:28:41 UTC (rev 2793)
+++ jcr/trunk/exo.jcr.component.webdav/src/test/java/org/exoplatform/services/jcr/webdav/command/TestPropFind.java 2010-07-15 13:36:39 UTC (rev 2794)
@@ -161,7 +161,7 @@
- public void _testPropWithPercent() throws Exception
+ public void testPropWithPercent() throws Exception
{
String content = TestUtils.getFileContent();
String file = TestUtils.getFileName();
More information about the exo-jcr-commits
mailing list