Note that there are some explanatory texts on larger screens.

plurals
  1. POpreg_match kills page
    primarykey
    data
    text
    <p>I am using preg_match to find and remove evaled base64 encoded viruses within files.</p> <p>the regex bewlow:</p> <pre><code>/\s*eval\s*\(\s*base64_decode\s*\(\s*('[a-zA-Z0-9\+\/]*={0,2}'|"[a-zA-Z0-9\+\/]*={0,2}")\s*\)\s*\s*\)\s*(;)?\s*/ </code></pre> <p>matches the following code:</p> <pre><code>eval(base64_decode("BASE64+ENCODED+VIRUS+HERE")); </code></pre> <p>The above regex works fine.</p> <p>I wanted to match base64 strings word-wrapped via concatenations. So it should match the following as well "BASE64+EN" . "CODED+VIRUS+HERE".</p> <p>So I changed the regex into:</p> <pre><code>/\s*eval\s*\(\s*base64_decode\s*\(\s*\'([a-zA-Z0-9\+\/]*(\'\s*\.\s*\')?[a-zA-Z0-9\+\/]*)*={0,2}\'|"([a-zA-Z0-9\+\/]*("\s*\.\s*")?[a-zA-Z0-9\+\/]*)*={0,2}"\s*\)\s*\s*\)\s*(;)?\s*/ </code></pre> <p>Which finds a partial match for:</p> <pre><code>"BASE64+ENCODED+VIRUS+HERE")); </code></pre> <p>But when I try to apply the match on this entire file: <a href="http://pastebin.com/ED8sFUP0" rel="nofollow noreferrer">http://pastebin.com/ED8sFUP0</a> the page dies with browser message "The connection to the server was reset while the page was loading.".</p> <p>I have error reporting activated:</p> <pre><code>error_reporting(E_ALL); ini_set('display_errors', TRUE); ini_set('scream.enabled', TRUE); </code></pre> <p>But nothing shows up not here and not in apache's error logs either.</p> <p>The very same regex when used on files that do not contain the offending string works as expected; preg_match does not return boolean false it returns 0 meaning that there was no regex error and that it did not find any matches.</p> <p>My concern is not necessarily why the regex finds only a partial match. That's probably some typo I made that happens to work.</p> <p>I want to know when and how does the regex compiler fail break the entire process chain</p> <pre><code>apache &gt; php &gt; regex_compiler </code></pre> <p>I understand that it may very well be "because" of my regex that just happens compile correctly but not match correctly. And it might cause something bad down the road. But my interest is why the regex compiler fails with no error and how I can get the error message that is should be yielding.</p> <p>Something similar is discussed but unresolved here: <a href="https://stackoverflow.com/questions/9447837/php-preg-match-all-kills-page-for-unknown-reason">php preg_match_all kills page for unknown reason</a></p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload