On Thu, Oct 15, 2009 at 09:00:34AM +0200, Ladislav Slezak wrote:
> ref: refs/heads/master
> commit 5873805e9683c113cf27eabd6406ba3a7051d0c0
> Author: Ladislav Slezak <[email protected]>
> Date:   Thu Oct 15 09:00:34 2009 +0200
> 
>     added IPv6 test to the SMTP input validation script
> ---
>  .../app/views/mail_settings/index.html.erb         |    4 +++-
>  1 files changed, 3 insertions(+), 1 deletions(-)
> 
> diff --git a/plugins/mail_settings/app/views/mail_settings/index.html.erb 
> b/plugins/mail_settings/app/views/mail_settings/index.html.erb
> index 374b047..50b6025 100644
> --- a/plugins/mail_settings/app/views/mail_settings/index.html.erb
> +++ b/plugins/mail_settings/app/views/mail_settings/index.html.erb
> @@ -14,7 +14,9 @@
>          // FQDN: http://regexlib.com/REDetails.aspx?regexp_id=391
>          || 
> /^([a-zA-Z0-9]([a-zA-Z0-9\-]{0,61}[a-zA-Z0-9])?\.)+[a-zA-Z]{2,6}$/.test(value)
>          // IPv4: http://regexlib.com/REDetails.aspx?regexp_id=32
> -        || 
> /^(25[0-5]|2[0-4][0-9]|[0-1]{1}[0-9]{2}|[1-9]{1}[0-9]{1}|[1-9])\.(25[0-5]|2[0-4][0-9]|[0-1]{1}[0-9]{2}|[1-9]{1}[0-9]{1}|[1-9]|0)\.(25[0-5]|2[0-4][0-9]|[0-1]{1}[0-9]{2}|[1-9]{1}[0-9]{1}|[1-9]|0)\.(25[0-5]|2[0-4][0-9]|[0-1]{1}[0-9]{2}|[1-9]{1}[0-9]{1}|[0-9])$/.test(value);
> +        || 
> /^(25[0-5]|2[0-4][0-9]|[0-1]{1}[0-9]{2}|[1-9]{1}[0-9]{1}|[1-9])\.(25[0-5]|2[0-4][0-9]|[0-1]{1}[0-9]{2}|[1-9]{1}[0-9]{1}|[1-9]|0)\.(25[0-5]|2[0-4][0-9]|[0-1]{1}[0-9]{2}|[1-9]{1}[0-9]{1}|[1-9]|0)\.(25[0-5]|2[0-4][0-9]|[0-1]{1}[0-9]{2}|[1-9]{1}[0-9]{1}|[0-9])$/.test(value)
> +        // IPv6: http://regexlib.com/REDetails.aspx?regexp_id=906 + allow 
> lowercase hexa letters (a-f)
> +        || 
> /^(^(([0-9A-Fa-f]{1,4}(((:[0-9A-Fa-f]{1,4}){5}::[0-9A-Fa-f]{1,4})|((:[0-9A-Fa-f]{1,4}){4}::[0-9A-Fa-f]{1,4}(:[0-9A-Fa-f]{1,4}){0,1})|((:[0-9A-Fa-f]{1,4}){3}::[0-9A-Fa-f]{1,4}(:[0-9A-Fa-f]{1,4}){0,2})|((:[0-9A-Fa-f]{1,4}){2}::[0-9A-Fa-f]{1,4}(:[0-9A-Fa-f]{1,4}){0,3})|(:[0-9A-Fa-f]{1,4}::[0-9A-Fa-f]{1,4}(:[0-9A-Fa-f]{1,4}){0,4})|(::[0-9A-Fa-f]{1,4}(:[0-9A-Fa-f]{1,4}){0,5})|(:[0-9A-Fa-f]{1,4}){7}))$|^(::[0-9A-Fa-f]{1,4}(:[0-9A-Fa-f]{1,4}){0,6})$)|^::$)|^((([0-9A-Fa-f]{1,4}(((:[0-9A-Fa-f]{1,4}){3}::([0-9A-Fa-f]{1,4}){1})|((:[0-9A-Fa-f]{1,4}){2}::[0-9A-Fa-f]{1,4}(:[0-9A-Fa-f]{1,4}){0,1})|((:[0-9A-Fa-f]{1,4}){1}::[0-9A-Fa-f]{1,4}(:[0-9A-Fa-f]{1,4}){0,2})|(::[0-9A-Fa-f]{1,4}(:[0-9A-Fa-f]{1,4}){0,3})|((:[0-9A-Fa-f]{1,4}){0,5})))|([:]{2}[0-9A-Fa-f]{1,4}(:[0-9A-Fa-f]{1,4}){0,4})):|::)((25[0-5]|2[0-4][0-9]|[0-1]?[0-9]{0,2})\.){3}(25[0-5]|2[0-4][0-9]|[0-1]?[0-9]{0,2})$$/.test(value);
>  
__        _______ _____ ___ _
\ \      / /_   _|  ___|__ \ |
 \ \ /\ / /  | | | |_    / / |
  \ V  V /   | | |  _|  |_||_|
   \_/\_/    |_| |_|    (_)(_)  [alt="WTF?!", thank you figlet.rpm]

This is an unreadable, unmaintainable black box.
Are you sure there is no typo in there?
In other words, even though a tool might report good test coverage, you
will never cover enough. (but this is .js, no tests here anyway)

How about using the regex only to detect four dot separated numbers
and then some arithmetic condition in a loop.

-- 
Martin Vidner, YaST developer
http://en.opensuse.org/User:Mvidner

Kuracke oddeleni v restauraci je jako fekalni oddeleni v bazenu
-- 
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to