Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Fix Relative Path Traversal
  • Loading branch information
ThexXTURBOXx committed Feb 14, 2022
1 parent c238b60 commit d064c19
Showing 1 changed file with 13 additions and 5 deletions.
Expand Up @@ -92,17 +92,25 @@ static String escapeType(String id) {
return escapeBuff.toString();
}

static String escapeId(String id) {
StringBuilder escapeBuff = new StringBuilder();
escapeId0(escapeBuff, id);
return escapeBuff.toString();
}

static void escapeId0(StringBuilder sb, String id) {
for (int i = 0; i < id.length(); ++i) {
char c = id.charAt(i);
escape1(sb, c);
escapeId1(sb, c);
}
}

static String escapeId(String id) {
StringBuilder escapeBuff = new StringBuilder();
escapeId0(escapeBuff, id);
return escapeBuff.toString();
static void escapeId1(final StringBuilder buf, char c) {
if (c == '\\' || c == '/' || c == '.') {
buf.append(String.format("\\u%04x", (int) c));
} else {
escape1(buf, c);
}
}

static void escape1(final StringBuilder buf, char c) {
Expand Down

0 comments on commit d064c19

Please sign in to comment.