Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Require separator to prevent suffix matching #41

Closed
wants to merge 1 commit into from
Closed
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
10 changes: 6 additions & 4 deletions src/globalreplace/FGUI.java
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ public static Wiki login(String domain)
JTextField tf = new JTextField(12);
JPasswordField pf = new JPasswordField(12);

for (int i = 0; i < 3; i++)
while (true)
{
if (JOptionPane.showConfirmDialog(null, buildForm("Login", new JLabel("User: "), tf, new JLabel("Password: "), pf),
"Login", JOptionPane.OK_CANCEL_OPTION, JOptionPane.PLAIN_MESSAGE) != JOptionPane.OK_OPTION)
Expand All @@ -119,11 +119,13 @@ public static Wiki login(String domain)
}
catch (Throwable e)
{
JOptionPane.showConfirmDialog(null, "User/Password not recognized. Try again?");
String reason = "Failed to login."; // TODO better reason
if (JOptionPane.OK_OPTION != JOptionPane.showConfirmDialog(null, reason + " Try again?"))
break;
}
}
showErrorAndExit("Failed login 3 times. Program exiting", 0);
return null; // never reaches here - shut up compiler
System.exit(0);
return null;
}

/**
Expand Down
5 changes: 4 additions & 1 deletion src/globalreplace/GlobalReplace.java
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ private void doJob() {
arrobject[1] = TITLE;
wiki.edit(
list.get(i).x,
text.replaceAll(this.old_name_regex, this.new_name),
text.replaceAll(this.old_name_regex, "$1" + this.new_name),
String.format(this.reason, arrobject));
}
BAR.setValue(list.size());
Expand Down Expand Up @@ -307,6 +307,9 @@ private void makeRegex() {
this.old_name_regex = "(" + Character.toLowerCase(char0) + "|"
+ Character.toUpperCase(char0) + ")"
+ this.old_name_regex.substring(1);
// The regex must only match when a special char separates the file name from the previous text
String seperator = "(\n|\\[|\\]|\\||:)";
this.old_name_regex = seperator + this.old_name_regex;
}

/**
Expand Down