PasswordMaker Forums
Firefox/SeaMonkey/Mozilla/Netscape/Flock Browser Extension => Bugs => Topic started by: tanstaafl on October 24, 2007, 06:52:53 PM
-
Hey Eric...
I don't use regex patterns, but I think the one that is on the Pattern Creation windows is wrong...
I'm clueless when it comes to regex and escaping characters, but, in the example, all of the dots (.) are escaped, except the very last one...
Shouldn't that last escape character be after the last slash, and before the trailing dot (the one right before the asterisk)?
-
Are you talking about this page (http://passwordmaker.sourceforge.net/help/patterns.html)? If not, then what? If yes, then which example?
-
No, sorry - I'm talking about the add/edit pattern window in the extension... see below...
-
That's correct. Normally a dot means match any character. It's basically a ? in the wildcard setup. (Actually, the wildcard patterns are translated to regular expressions anyway, so ? become plain old ., and * becomes .*)
BTW, is PasswordMaker checking all possible characters in the wildcards to make sure a regex pattern doesn't screw things up too much?
-
That's correct. Normally a dot means match any character. It's basically a ? in the wildcard setup. (Actually, the wildcard patterns are translated to regular expressions anyway, so ? become plain old ., and * becomes .*)
So, you are confirming that the example in the PWM dialog is wrong?
BTW, is PasswordMaker checking all possible characters in the wildcards to make sure a regex pattern doesn't screw things up too much?
? Can you elaborate on what you mean? A wildcard is any character - so what is there to check?
-
If the regular expression were to be expressed as a wildcard (and ignoring that it allows both http and https, just http) it would be this: http://mail.yahoo.com/*
But if you remove the escaping of the dots, then it would be: http://mail?yahoo?com/*
See what I mean?
-
Tanstaalf, when you find a spare 30 minutes just read a regexp tutorial. That's all it takes. Print it out and read during your commute. You definitely have the skills to grok it.
-
Why the last slash in the regexp expression must be escaped, but the doubleslashes at the beginning are not?
-
Why the last slash in the regexp expression must be escaped, but the doubleslashes at the beginning are not?
They all should be escaped. Where are you looking?
-
Why the last slash in the regexp expression must be escaped, but the doubleslashes at the beginning are not?
They all should be escaped. Where are you looking?
I think he's referring to the "add/edit pattern window in the extension" as shown by tanstaafl in the message above
it shows https?://mail\.yahoo\.com\/.* but should be https?:\/\/mail\.yahoo\.com\/.* I think
-
I'm not sure if the slashes need to be escaped in the first place actually.
[edit] I should clarify that a bit. The way you define regular expressions in JavaScript (At least with how it used in PasswordMaker) does not use '/' to surround the epression. And since slashes have no meaning when they're not use to surround the expression, there's no need to escape them. (Also, it's possible to use other characters. When I make regular expressions at work that deal with urls, I use ~ or something similar)
-
Forward slash is not a special character in Javascript regular expressions (http://developer.mozilla.org/en/docs/Core_JavaScript_1.5_Reference:Global_Objects:RegExp#Special_characters_in_regular_expressions), so it doesn't need to be escaped. Perhaps you're thinking of backslashes.
-
There's a forward slash that is escaped in the example for PasswordMaker. That appears to be causing some recent confusion right now.
-
There's a forward slash that is escaped in the example for PasswordMaker. That appears to be causing some recent confusion right now.
Yes the example shows https?://mail\.yahoo\.com\/.*
I was thinking of perl regular expressions!?? Should have realized they would be Javascript! The example should perhaps be 'https?://mail\.yahoo\.com/.*' i.e. the last / is not escaped.
Does the documentation/help mention that the regular expressions should be Javascript ones? I find many programs specify they support regular expression but don't specify what kind. This is rather annoying as there are many variations and one never knows what is going to work & what isn't. Regular expressions can be hard enough to think through even if one is sure of what is supported!
In the case of Passwordmaker I want to be fairly sure they are correct so I don't match phishing sites for example.
-
I have just read through some more of the Advanced usage wiki and see that it does give good documentation of the type of regexps supported! Well done whoever wrote it.
I think the example mentioned above should still be changed to clear up any confusion it may cause.