php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #22371 ereg_replace moving ! to start of string
Submitted: 2003-02-22 01:22 UTC Modified: 2003-03-09 18:59 UTC
From: phpbugreport at webfroot dot co dot nz Assigned:
Status: No Feedback Package: Regexps related
PHP Version: 4.3.0 OS: Windows XP
Private report: No CVE-ID: None
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please — but make sure to vote on the bug!
Your email address:
MUST BE VALID
Solve the problem:
46 - 21 = ?
Subscribe to this entry?

 
 [2003-02-22 01:22 UTC] phpbugreport at webfroot dot co dot nz
Running Apache 1.3 as a service on Windows XP

$text = ereg_replace ("<a[^>]+href *= *([^ ]+)[^>]*>", "<a href=\\1>", $text);

The above line of code is supposed to find all a tags and strip any attributes except href.  However:

$text = "bacon <a href='http://www.whatever.com' title='hello!'>hello</a>";

will be set to:
bacon !<a href='http://www.whatever.com' title='hello'>hello</a>

How in the hell did that exclaim get to the start of the a tag?  Maybe I'm just doing something wrong, but it looks like a bug to me.

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2003-02-22 14:15 UTC] iliaa@php.net
Please try using this CVS snapshot:

  http://snaps.php.net/php4-STABLE-latest.tar.gz
 
For Windows:
 
  http://snaps.php.net/win32/php4-win32-STABLE-latest.zip

With latest CVS I get:
bacon <a href='http://www.whatever.com'>hello</a>
as the result of the regular expression.
 [2003-03-09 18:59 UTC] sniper@php.net
No feedback was provided. The bug is being suspended because
we assume that you are no longer experiencing the problem.
If this is not the case and you are able to provide the
information that was requested earlier, please do so and
change the status of the bug back to "Open". Thank you.


 
PHP Copyright © 2001-2022 The PHP Group
All rights reserved.
Last updated: Tue Jan 18 01:03:48 2022 UTC