Browse files

MODE-1823 - Fixed additional problems in WebDAV servlet encoding.

  • Loading branch information...
1 parent 2e7e439 commit d63fa54076a5d042e702f3a12c4bc55c7d281614 @hchiorean hchiorean committed with rhauch Mar 7, 2013
View
2 web/modeshape-webdav/src/main/java/org/modeshape/webdav/fromcatalina/URLEncoder.java
@@ -69,7 +69,7 @@ public String encode( String path ) {
ByteArrayOutputStream buf = new ByteArrayOutputStream(maxBytesPerChar);
OutputStreamWriter writer = null;
try {
- writer = new OutputStreamWriter(buf, "UTF8");
+ writer = new OutputStreamWriter(buf, "UTF-8");
} catch (Exception e) {
LOG.error(e, new TextI18n("Error in encode <" + path + ">"));
writer = new OutputStreamWriter(buf);
View
12 web/modeshape-webdav/src/main/java/org/modeshape/webdav/methods/AbstractMethod.java
@@ -154,7 +154,7 @@ protected String getRelativePath( HttpServletRequest request ) {
if ((result == null) || (result.equals(""))) {
result = "/";
}
- return encodedResult(result);
+ return result;
}
// No, extract the desired path directly from the request
@@ -163,17 +163,9 @@ protected String getRelativePath( HttpServletRequest request ) {
if ((result == null) || (result.equals(""))) {
result = "/";
}
- //always convert to UTF-8
- return encodedResult(result);
+ return result;
}
- private String encodedResult( String result ) {
- try {
- return new String(result.getBytes(), "UTF-8");
- } catch (Exception e){
- throw new RuntimeException(e);
- }
- }
/**
* creates the parent path from the given path by removing the last '/' and everything after that
View
2 web/modeshape-webdav/src/main/java/org/modeshape/webdav/methods/DoCopy.java
@@ -335,7 +335,7 @@ private String parseDestinationHeader( HttpServletRequest req,
}
// Remove url encoding from destination
- destinationPath = RequestUtil.URLDecode(destinationPath, "UTF8");
+ destinationPath = RequestUtil.URLDecode(destinationPath, "UTF-8");
int protocolIndex = destinationPath.indexOf("://");
if (protocolIndex >= 0) {
View
18 web/modeshape-webdav/src/main/java/org/modeshape/webdav/methods/DoGet.java
@@ -142,19 +142,25 @@ protected void folderBody( ITransaction transaction,
childrenTemp.append("\">");
childrenTemp.append("<td>");
childrenTemp.append("<a href=\"");
- String requestURL = req.getRequestURL().toString();
- childrenTemp.append(requestURL);
- if (!requestURL.endsWith("/")) {
- childrenTemp.append("/");
+
+ StringBuffer childURL = req.getRequestURL();
+ if (!(childURL.charAt(childURL.length() - 1) == '/')) {
+ childURL.append("/");
}
- childrenTemp.append(child);
+
+ //we need to URL encode the child, but just the special chars, UTF-8 encoding is done at the end of this method
+ childURL.append(URL_ENCODER.encode(child));
+
StoredObject obj = store.getStoredObject(transaction, path + "/" + child);
if (obj == null) {
LOG.error(new TextI18n("Should not return null for " + path + "/" + child));
}
if (obj != null && obj.isFolder()) {
- childrenTemp.append("/");
+ childURL.append("/");
}
+
+ childrenTemp.append(childURL);
+
childrenTemp.append("\">");
childrenTemp.append(child);
childrenTemp.append("</a></td>");

0 comments on commit d63fa54

Please sign in to comment.