Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 34 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# Gradle files
.gradle/
build/

# Local configuration file (sdk path, etc)
local.properties
/local.properties

# Log/OS Files
*.log

# Android Studio generated files and folders
captures/
.externalNativeBuild/
.cxx/
*.apk
output.json

# IntelliJ
*.iml
.idea/
misc.xml
deploymentTargetDropDown.xml
render.experimental.xml

# Keystore files
*.jks
*.keystore

# Google Services (e.g. APIs or Firebase)
google-services.json

# Android Profiling
*.hprof
42 changes: 32 additions & 10 deletions app/src/main/java/modder/hub/dexeditor/fragment/SearchFragment.java
Original file line number Diff line number Diff line change
Expand Up @@ -755,24 +755,46 @@ public void run() {
int countInClass = 0;

if (type.equals("String")) {
String findPattern = exactlyMatch ? "\"" + Pattern.quote(findQuery) + "\"" : Pattern.quote(findQuery);
String replacePattern = exactlyMatch ? "\"" + java.util.regex.Matcher.quoteReplacement(replaceWith) + "\"" : java.util.regex.Matcher.quoteReplacement(replaceWith);
Pattern p = Pattern.compile(findPattern, matchCase ? 0 : Pattern.CASE_INSENSITIVE);
java.util.regex.Matcher m = p.matcher(originalText);
Matcher lm = Pattern.compile("\"((?:\\\\.|[^\"\\\\])*)\"").matcher(originalText);
StringBuffer sb = new StringBuffer();
while (m.find()) {
countInClass++;
m.appendReplacement(sb, replacePattern);

int flag = matchCase ? 0 : Pattern.CASE_INSENSITIVE;
String q1 = isRegex ? findQuery : Pattern.quote(findQuery);
String q2 = exactlyMatch ? "^" + q1 + "$" : q1;
Pattern innerFind = Pattern.compile(q2, flag);

while (lm.find()) {
Matcher im = innerFind.matcher(lm.group(1));
StringBuffer inner = new StringBuffer();
while (im.find()) {
countInClass++;
try {
im.appendReplacement(inner, isRegex ? replaceWith : Matcher.quoteReplacement(replaceWith));
} catch (IndexOutOfBoundsException | IllegalArgumentException e) {
errorClasses.add(className + ": invalid replacement pattern - " + e.getMessage());
return;
}
}
im.appendTail(inner);

String newLiteral = "\"" + inner + "\"";
lm.appendReplacement(sb, Matcher.quoteReplacement(newLiteral));
}
m.appendTail(sb);
lm.appendTail(sb);
modifiedText = sb.toString();
} else {
if (isRegex) {
Matcher m = compiledPattern.matcher(originalText);
StringBuffer sb = new StringBuffer();
while (m.find()) {
countInClass++;
m.appendReplacement(sb, Matcher.quoteReplacement(replaceWith));
try {
m.appendReplacement(sb, replaceWith);
} catch (IndexOutOfBoundsException | IllegalArgumentException e) {
// invalid group reference
errorClasses.add(className + ": invalid replacement pattern - " + e.getMessage());
return;
}
}
m.appendTail(sb);
modifiedText = sb.toString();
Expand Down Expand Up @@ -881,7 +903,7 @@ private String generateSmali(ClassDef classDef) throws Exception {
@SuppressLint("NotifyDataSetChanged")
private void onPostExecute(DexEditorActivity activity) {
if (progressDialog.isShowing()) progressDialog.dismiss();
Notify_MT.Notify(activity, "Info", "Total replaced " + replacedCount.get() + "times in " + affectedClasses.get() + "classes." , "Close");
Notify_MT.Notify(activity, "Info", "Total replaced " + replacedCount.get() + " times in " + affectedClasses.get() + " classes." , "Close");
if (!errorClasses.isEmpty()) {
showErrorDialog(activity);
}
Expand Down