unescape file names, this fixes unsharing of files with html characters
This commit is contained in:
@ -110,7 +110,7 @@ public class FilesServlet extends HttpServlet {
|
||||
String pathElements = req.getParameter("path");
|
||||
File current = null;
|
||||
for (String element : pathElements.split(",")) {
|
||||
element = Base64.decodeToString(element);
|
||||
element = Util.unescapeHTMLinXML(Base64.decodeToString(element));
|
||||
if (current == null)
|
||||
current = new File(element);
|
||||
else
|
||||
|
@ -4,6 +4,8 @@ public class Util {
|
||||
|
||||
private static final String escapeChars[] = {"&", "\"", "<", ">", "'"};
|
||||
private static final String escapeCodes[] = {"&amp;", "&quot;", "&lt;", "&gt;", "&apos;"};
|
||||
|
||||
private static final String escapedCodes[] = {"&", """, "<", ">", "'"};
|
||||
|
||||
/**
|
||||
* Double-Escape an HTML string for inclusion in XML
|
||||
@ -18,4 +20,13 @@ public class Util {
|
||||
}
|
||||
return escaped;
|
||||
}
|
||||
|
||||
public static String unescapeHTMLinXML(String escaped) {
|
||||
if (escaped == null) return null;
|
||||
String unescaped = escaped;
|
||||
for (int i = 0; i < escapedCodes.length; i++) {
|
||||
unescaped = unescaped.replace(escapedCodes[i], escapeChars[i]);
|
||||
}
|
||||
return unescaped;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user