aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEinar Egilsson2009-10-26 08:13:15 +0000
committerEinar Egilsson2009-10-26 08:13:15 +0000
commit88a382a54500d6572446b453a560ef072128a393 (patch)
tree178d15aff278eebbfa98f3b743023d054ac13fc8
parent7a35fcd096f1fc4f81fc9cbc5d41ced28b752a89 (diff)
Ready for final test
git-svn-id: http://einaregilsson.googlecode.com/svn/mozilla/redirector/trunk@288 119bf307-c92d-0410-89bd-8f53e6181181
-rw-r--r--chrome/content/code/editRedirect.xul.js20
-rw-r--r--chrome/locale/en-US/redirector.properties6
2 files changed, 22 insertions, 4 deletions
diff --git a/chrome/content/code/editRedirect.xul.js b/chrome/content/code/editRedirect.xul.js
index 72513e8..0902645 100644
--- a/chrome/content/code/editRedirect.xul.js
+++ b/chrome/content/code/editRedirect.xul.js
@@ -34,6 +34,7 @@ var EditRedirect = {
onAccept : function() {
var args = window.arguments[0];
+ var msg, title;
args.saved = true;
this.saveValues(args.redirect);
@@ -42,12 +43,25 @@ var EditRedirect = {
if (!/^\s*$/.test(args.redirect.exampleUrl)) {
var result = args.redirect.getMatch(args.redirect.exampleUrl);
if (!result.isMatch) {
- //TODO: warn about match
+ title = this.strings.getString('warningExampleUrlDoesntMatchPatternTitle');
+ msg = this.strings.getString('warningExampleUrlDoesntMatchPattern');
+ var ps = Components.classes["@mozilla.org/embedcomp/prompt-service;1"].getService(Components.interfaces.nsIPromptService);
+ var rv = ps.confirmEx(window, title, msg, ps.STD_YES_NO_BUTTONS, ps.BUTTON_TITLE_YES, ps.BUTTON_TITLE_NO, null, null, {});
+ return rv == 0;
} else {
- var resultUrl = '';
+ var resultUrl = result.redirectTo;
+ if (!resultUrl.match(/https?:/)) {
+ var ioService = Components.classes["@mozilla.org/network/io-service;1"].getService(Components.interfaces.nsIIOService);
+ var uri = ioService.newURI(args.redirect.exampleUrl, null, null);
+ resultUrl = uri.resolve(resultUrl);
+ }
+
var secondResult = args.redirect.getMatch(resultUrl);
if (secondResult.isMatch) {
- //TODO: Warn about recursive match...
+ title = this.strings.getString('errorExampleUrlMatchesRecursiveTitle');
+ msg = this.strings.getFormattedString('errorExampleUrlMatchesRecursive', [args.redirect.exampleUrl, resultUrl]);
+ this.msgBox(title, msg);
+ return false;
}
}
}
diff --git a/chrome/locale/en-US/redirector.properties b/chrome/locale/en-US/redirector.properties
index 4f16de5..128d08e 100644
--- a/chrome/locale/en-US/redirector.properties
+++ b/chrome/locale/en-US/redirector.properties
@@ -26,4 +26,8 @@ allExistedMessageSingular=The single redirect in the file was identical to an ex
importedNone=There were no usable redirects in the given file, no redirects were imported.
importResult=Import results
invalidRedirectTitle=Redirector Add-on: Invalid Redirect detected
-invalidRedirectText=The pattern "%S" redirected the url %S to %S which also matches the pattern. This will cause an endless loop and so the redirect has been disabled to prevent this from happening. You should edit this redirect to fix it. \ No newline at end of file
+invalidRedirectText=The pattern "%S" redirected the url %S to %S which also matches the pattern. This will cause an endless loop and so the redirect has been disabled to prevent this from happening. You should edit this redirect to fix it.
+warningExampleUrlDoesntMatchPatternTitle=Warning: Example url does not match redirect
+warningExampleUrlDoesntMatchPattern=The example url does not match the redirect specified. Are you sure you want to save this redirect?
+errorExampleUrlMatchesRecursiveTitle=Error: Recursive match detected
+errorExampleUrlMatchesRecursive=The example url %S matches the redirect and would redirect you to %S, which also matches the redirect. This is not allowed as it can cause an endless loop of requests. \ No newline at end of file