View Issue Details

IDProjectCategoryView StatusLast Update
0005694mantisbtbugtrackerpublic2005-07-23 02:12
Reportermorganparry Assigned Tograngeway  
PrioritynormalSeveritycrashReproducibilityalways
Status closedResolutionno change required 
Product Version0.19.0 
Summary0005694: Long URLs cause crashes in string_insert_hrefs()
Description

We're running Apache v2.0.53, PHP v4.3.11 and MySQL v4.1.10. Attempting to view a bug where the description or bugnote contains a very long URL will crash Apache, seemingly where it's trying to do some regular expression stuff inside string_insert_hrefs().

The particular URL we saw this on was around 500 characters in length and is a POST style form URL, containing many (around 60) fields.

TagsNo tags attached.
Attached Files
test.zip (788 bytes)

Relationships

related to 0005695 closedgrangeway Long pre sections cause crashes in string_nl2br() 
child of 0005460 closedvboctor Critical Issues to Fix for Mantis 1.0.0 Release 

Activities

morganparry

morganparry

2005-06-01 10:09

reporter   ~0010319

This is related to 0005695.

Replacing the relevant section of code with the latest CVS version either did not fix the problem or was identical anyway.

grangeway

grangeway

2005-06-01 17:39

reporter   ~0010323

Hi Morgan,

I've just tried calling string_insert_href's from a command line php script with a 1000 character url:

$foo = "http://bugs.mantisbt.org/view.php?id=5694&sdf=dfsjklfjksdlfjksdljfsdkl&sdf=dfsjklfjksdlfjksdljfsdkl&sdf=dfsjklfjksdlfjksdljfsdkl&sdf=dfsjklfjksdlfjksdljfsdkl&sdf=dfsjklfjksdlfjksdljfsdkl&sdf=dfsjklfjksdlfjksdljfsdkl&sdf=dfsjklfjksdlfjksdljfsdkl&sdf=dfsjklfjksdlfjksdljfsdkl&sdf=dfsjklfjksdlfjksdljfsdkl&sdf=dfsjklfjksdlfjksdljfsdkl&sdf=dfsjklfjksdlfjksdljfsdkl&sdf=dfsjklfjksdlfjksdljfsdkl&sdf=dfsjklfjksdlfjksdljfsdkl&sdf=dfsjklfjksdlfjksdljfsdkl&sdf=dfsjklfjksdlfjksdljfsdkl&sdf=dfsjklfjksdlfjksdljfsdkl&sdf=dfsjklfjksdlfjksdljfsdkl&sdf=dfsjklfjksdlfjksdljfsdkl&sdf=dfsjklfjksdlfjksdljfsdkl&sdf=dfsjklfjksdlfjksdljfsdkl&sdf=dfsjklfjksdlfjksdljfsdkl&sdf=dfsjklfjksdlfjksdljfsdkl&sdf=dfsjklfjksdlfjksdljfsdkl&sdf=dfsjklfjksdlfjksdljfsdkl&sdf=dfsjklfjksdlfjksdljfsdkl&sdf=dfsjklfjksdlfjksdljfsdkl&sdf=dfsjklfjksdlfjksdljfsdkl&sdf=dfsjklfjksdlfjksdljfsdkl&sdf=dfsjklfjksdlfjksdljfsdkl&sdf=dfsjklfjksdlfjksdljfsdkl&sdf=dfsjklfjksdlfjksdljfsdkl&sdf=dfsjklfjksdlfjksdljfsdkl&sdf=dfsjklfjksdlfjksdljfsdkl&sdf=dfsjklfjksdlfjksdljfsdkl";

echo string_insert_hrefs($foo);
function string_insert_hrefs( $p_string ) {
$p_string = pregreplace( '/(([[:alpha:]][-+.[:alnum:]]*):\/\/(%[[:digit:]A-Fa-f]{2}|[-.!~\';\/?%^\\:@&={|}+$#(),[][:alnum:]])+)/se', "'<a href=\"'.rtrim('\1','.').'\">\1</a> [<a href=\"'.rtrim('\1','.').'\" target=\"_blank\">^</a>]'", $p_string);
$t_atom = '[^\'@\'](?:[^()<>@,;:\\".[]\000-\037\177 &]+)';
$p_string = preg_replace( '/(?<=^|"|<|[\s\:>\n\r])('.$t_atom.'(?:.'.$t_atom.')
\@'.$t_atom.'(?:.'.$t_atom.')*)(?=$|"|>|[\s\,\<\n\r])/s',
'<a href="mailto:\1" target="_new">\1</a>', $p_string);
return $p_string;
}
This case works fine at the command prompt for me, albeit i've tried with php5.04 on windows:

PHP 5.0.5-dev (cli) (built: Apr 2 2005 10:19:49)
Copyright (c) 1997-2004 The PHP Group
Zend Engine v2.0.4-dev, Copyright (c) 1998-2004 Zend Technologies
with Xdebug v2.0.0beta1, Copyright (c) 2002, 2003, 2004, by Derick Rethans

morganparry

morganparry

2005-06-02 05:20

reporter   ~0010329

Try the attached file. Oddly it only causes a crash when run with PHP under Apache. If I try running it via a command-line PHP, it appears to work ok...

grangeway

grangeway

2005-06-02 06:39

reporter   ~0010331

Out of interest,
Is this under windows or linux?

morganparry

morganparry

2005-06-02 07:14

reporter   ~0010332

Windows 2000 SP4.

grangeway

grangeway

2005-06-02 12:03

reporter   ~0010338

ok, that test script works for me under:

XP, Apache/2.0.53 (Win32) PHP/5.0.5-dev.

morganparry

morganparry

2005-06-03 05:15

reporter   ~0010342

I could try upgrading to PHP 5. However, was Mantis v0.19.x compatible with PHP 5 or were there fixes made since?

morganparry

morganparry

2005-06-23 06:44

reporter   ~0010617

Upgrading to PHP v5.0.4 fixed this.

grangeway

grangeway

2005-07-16 13:27

reporter   ~0010812

I think for now, this can be closed. It's only ever been reported once, and looks like it's a php issue which does not exist in latest php versoins.