PasswordMaker Forums

Firefox/SeaMonkey/Mozilla/Netscape/Flock Browser Extension => Bugs => Topic started by: tanstaafl on October 24, 2007, 06:52:53 PM

Title: Pattern Example incorrect?
Post 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)?
Title: Re: Pattern Example incorrect?
Post by: Eric H. Jung on October 24, 2007, 07:56:49 PM
Are you talking about this page (http://passwordmaker.sourceforge.net/help/patterns.html)? If not, then what? If yes, then which example?
Title: Re: Pattern Example incorrect?
Post by: tanstaafl on October 24, 2007, 08:55:59 PM
No, sorry - I'm talking about the add/edit pattern window in the extension... see below...
Title: Re: Pattern Example incorrect?
Post by: Miquel 'Fire' Burns on October 25, 2007, 02:15:38 AM
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?
Title: Re: Pattern Example incorrect?
Post by: tanstaafl on October 25, 2007, 11:21:03 AM
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?

Quote
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?
Title: Re: Pattern Example incorrect?
Post by: Miquel 'Fire' Burns on October 26, 2007, 01:06:50 AM
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?
Title: Re: Pattern Example incorrect?
Post by: Eric H. Jung on October 26, 2007, 01:13:33 AM
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.
Title: Re: Pattern Example incorrect?
Post by: marr on February 12, 2008, 06:53:20 PM
Why the last slash in the regexp expression must be escaped, but the doubleslashes at the beginning are not?
Title: Re: Pattern Example incorrect?
Post by: Eric H. Jung on February 12, 2008, 07:35:54 PM
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?
Title: Re: Pattern Example incorrect?
Post by: dschwartfeger on May 07, 2008, 09:08:41 PM
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
Title: Re: Pattern Example incorrect?
Post by: Miquel 'Fire' Burns on May 08, 2008, 01:11:16 AM
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)
Title: Re: Pattern Example incorrect?
Post by: Eric H. Jung on May 08, 2008, 03:01:24 AM
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.
Title: Re: Pattern Example incorrect?
Post by: Miquel 'Fire' Burns on May 08, 2008, 04:03:08 AM
There's a forward slash that is escaped in the example for PasswordMaker. That appears to be causing some recent confusion right now.
Title: Re: Pattern Example incorrect?
Post by: dschwartfeger on May 10, 2008, 10:51:17 PM
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.
Title: Re: Pattern Example incorrect?
Post by: dschwartfeger on May 10, 2008, 11:32:00 PM
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.