From: babyluch06 at hotmail dot com Operating system: windows PHP version: 5.2.3 PHP Bug Type: Filesystem function related Bug description: fread is stripping text from the string before returning contents
Description: ------------ I'm using fread to retrieve the contents of a .js file. If within the file this string exists, '/g'. it strips this with a empty space and 'String' with empty space. If '/g' dosen't exists, everything works fine. heres the .js file function trim(str){ // str. remove whitespaces from left. remove whitespaces from right return str.replace(/^\s+/g, "").replace(/\s+$/g, ""); } String.prototype.trim = trim; The Apache and PHP i'm using comes from xampplite from apachefriends.org. I didn't make any configuration changes. I can send you the contents of phpinfo() if will help Reproduce code: --------------- if ($handle = @fopen($file, 'rb')) { $filesize = filesize( $file ); if ($contents = fread($handle, $filesize)) { $contents = file_get_contents( $file ); if ( eregi( 'trim.js' , $file ) ) { print "<br/><br/><h1>$contents</h1>"; } return $contents; fclose($handle); } else { $GLOBALS['IG_ERROR_PHP'] = $php_errormsg; $GLOBALS['IG_ERROR_SPEC'] = "$file"; IF ($return==TRUE) return 'ERR0104'; ELSE return FALSE; } } Expected result: ---------------- return the full contents Actual result: -------------- It strips certain text out, as explained above -- Edit bug report at http://bugs.php.net/?id=42321&edit=1 -- Try a CVS snapshot (PHP 4.4): http://bugs.php.net/fix.php?id=42321&r=trysnapshot44 Try a CVS snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=42321&r=trysnapshot52 Try a CVS snapshot (PHP 6.0): http://bugs.php.net/fix.php?id=42321&r=trysnapshot60 Fixed in CVS: http://bugs.php.net/fix.php?id=42321&r=fixedcvs Fixed in release: http://bugs.php.net/fix.php?id=42321&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=42321&r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=42321&r=needscript Try newer version: http://bugs.php.net/fix.php?id=42321&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=42321&r=support Expected behavior: http://bugs.php.net/fix.php?id=42321&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=42321&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=42321&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=42321&r=globals PHP 3 support discontinued: http://bugs.php.net/fix.php?id=42321&r=php3 Daylight Savings: http://bugs.php.net/fix.php?id=42321&r=dst IIS Stability: http://bugs.php.net/fix.php?id=42321&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=42321&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=42321&r=float No Zend Extensions: http://bugs.php.net/fix.php?id=42321&r=nozend MySQL Configuration Error: http://bugs.php.net/fix.php?id=42321&r=mysqlcfg