mirror of https://github.com/zlatinb/muwire
unescape file names, this fixes unsharing of files with html characters
parent
f579c8754f
commit
8c661ca1ae
|
@ -110,7 +110,7 @@ public class FilesServlet extends HttpServlet {
|
||||||
String pathElements = req.getParameter("path");
|
String pathElements = req.getParameter("path");
|
||||||
File current = null;
|
File current = null;
|
||||||
for (String element : pathElements.split(",")) {
|
for (String element : pathElements.split(",")) {
|
||||||
element = Base64.decodeToString(element);
|
element = Util.unescapeHTMLinXML(Base64.decodeToString(element));
|
||||||
if (current == null)
|
if (current == null)
|
||||||
current = new File(element);
|
current = new File(element);
|
||||||
else
|
else
|
||||||
|
|
|
@ -5,6 +5,8 @@ public class Util {
|
||||||
private static final String escapeChars[] = {"&", "\"", "<", ">", "'"};
|
private static final String escapeChars[] = {"&", "\"", "<", ">", "'"};
|
||||||
private static final String escapeCodes[] = {"&amp;", "&quot;", "&lt;", "&gt;", "&apos;"};
|
private static final String escapeCodes[] = {"&amp;", "&quot;", "&lt;", "&gt;", "&apos;"};
|
||||||
|
|
||||||
|
private static final String escapedCodes[] = {"&", """, "<", ">", "'"};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Double-Escape an HTML string for inclusion in XML
|
* Double-Escape an HTML string for inclusion in XML
|
||||||
* @param unescaped the unescaped string, may be null
|
* @param unescaped the unescaped string, may be null
|
||||||
|
@ -18,4 +20,13 @@ public class Util {
|
||||||
}
|
}
|
||||||
return escaped;
|
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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue