Given an obfuscated description, finds the new values for class names and updates the description. @param description @param oldNamestoClasses @return
(String description, Map<String, MappedClass> oldNamestoClasses)
| 17 | * @return |
| 18 | */ |
| 19 | public static String fixDesc(String description, Map<String, MappedClass> oldNamestoClasses) { |
| 20 | if (description == null || description.length() == 0 || isPrimitive(description)) { |
| 21 | return description; |
| 22 | } |
| 23 | if (description.contains("L") && description.contains(";")) { |
| 24 | if (description.startsWith("(") || (description.startsWith("L") || description.startsWith("[")) && description.endsWith(";")) { |
| 25 | String regex = "(?<=[L])[^;]*(?=;)"; |
| 26 | Pattern p = Pattern.compile(regex); |
| 27 | Matcher m = p.matcher(Pattern.quote(description)); |
| 28 | for (int i = 0; i < m.groupCount(); i++) { |
| 29 | String found = m.group(i); |
| 30 | description = description.replace(found, fixDesc(found, oldNamestoClasses)); |
| 31 | } |
| 32 | return description; |
| 33 | } |
| 34 | } else { |
| 35 | MappedClass mc = oldNamestoClasses.get(description); |
| 36 | if (mc == null) { |
| 37 | return description; |
| 38 | } |
| 39 | return mc.getNewName(); |
| 40 | } |
| 41 | return description; |
| 42 | } |
| 43 | |
| 44 | /** |
| 45 | * Unfixes descriptions. (Lknown/class/Name; --> Lobfu;) |
no test coverage detected