php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #862 problem in eregi()
Submitted: 1998-10-20 17:17 UTC Modified: 1998-10-29 22:04 UTC
From: markjr at easyDNS dot com Assigned:
Status: Closed Package: Misbehaving function
PHP Version: 3.0.5 OS: linux 2.0.35
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: markjr at easyDNS dot com
New email:
PHP Version: OS:

 

 [1998-10-20 17:17 UTC] markjr at easyDNS dot com
eregi("[^a-z0-9\.\-]", "test-ing") returns false
eregi("[^a-z0-9\-\.]", "test-ing") returns true

Switching the escaped "." and "-" causes the
pattern to fail erroneously. The behaviour goes
away if you use an inclusive regex (read:
lose the "^")

here's a short script to test with 

<?
function isValidAddr ($addr) {
        if(eregi("[^a-z0-9\-\.]",$addr)):
                return(false);
        else:
                return(true);
        endif;
        };

echo isValidAddr("Tesdt-jkjk") ? "true" : "false";
?>

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [1998-10-29 22:04 UTC] rasmus
You have a number of problems in your regular expressions there.  First, there is no such thing as \- and even if there was you would have to write it as \\- because inside a double-quoted string in PHP escape chars are parsed.  In order to get the eregi() function to see \- you would have to escape the \ and thus have \\-.  That isn't you problem though.  I quote from the Extended Regular Expression docs (see regex/regex.7 in the PHP distribution):
To  include  a  literal `]' in the list, make it the first
character (following a possible `^').  To include  a  lit-
eral `-', make it the first or last character, or the sec-
ond endpoint of a range.  To use  a  literal  `-'  as  the
first  endpoint of a range, enclose it in `[.' and `.]' to
make it a collating element (see below).  With the  excep-
tion  of  these  and some combinations using `[' (see next
paragraphs), all other special characters, including  `\',
lose  their  special significance within a bracket expres-
sion.
So, this tells you that you cannot put a '-' in the middle of a range like that.  I do not think this is a bug in PHP.  PHP's behaviour is entirely consistent with that definition.
 [2023-03-06 07:15 UTC] asghhs at gmail dot com
MYHR KOHLS is an online portal that enables Kohl's employees to access their HR information and manage their benefits. This portal provides employees with a convenient way to view and manage their payroll, vacation time, health benefits, and other HR related information. It also allows them to access a variety of tools such as tax forms, pension plans, and more. MYHR KOHLS is a great tool for employers as it helps them keep track of employee information in one place. It also simplifies the process of managing employee benefits and payrolls.
(https://myhrwork.com/kohls/myhr-kohls-login/)github.com
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Tue Jun 11 08:01:31 2024 UTC