Created
March 16, 2011 04:34
-
-
Save hamishcampbell/872020 to your computer and use it in GitHub Desktop.
Example of a regex expression that crashes Apache on Windows
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$rx = <<<'RX' | |
/ | |
( | |
(\\.) | # Any escaped character | |
([^<${]) | # Any character that isn't <, $ or { | |
(<[^%]) | # < if not followed by % | |
($[^A-Za-z_]) | # $ if not followed by A-Z, a-z or _ | |
({[^$]) | # { if not followed by $ | |
({$[^A-Za-z_]) # {$ if not followed A-Z, a-z or _ | |
)+ | |
/Sx | |
RX; | |
$string = <<<'STRING' | |
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"> | |
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" > | |
<head> | |
<% base_tag %> | |
<title>$Title » $SiteConfig.Title</title> | |
$MetaTags(false) | |
<link rel="shortcut icon" href="/favicon.ico" /> | |
<% require themedCSS(layout) %> | |
<% require themedCSS(typography) %> | |
<% require themedCSS(form) %> | |
<!--[if IE 6]> | |
<style type="text/css"> | |
@import url(themes/blackcandy/css/ie6.css); | |
</style> | |
<![endif]--> | |
<!--[if IE 7]> | |
<style type="text/css"> | |
@import url(themes/blackcandy/css/ie7.css); | |
</style> | |
<![endif]--> | |
</head> | |
<body> | |
<div id="BgContainer"> | |
<div id="Container"> | |
<div id="Header"> | |
$SearchForm | |
<h1>$SiteConfig.Title</h1> | |
<p>$SiteConfig.Tagline</p> | |
</div> | |
<div id="Navigation"> | |
<% include Navigation %> | |
</div> | |
<div class="clear"><!-- --></div> | |
<div id="Layout"> | |
$Layout | |
</div> | |
<div class="clear"><!-- --></div> | |
</div> | |
<div id="Footer"> | |
<% include Footer %> | |
</div> | |
</div> | |
</body> | |
</html> | |
STRING; | |
$result = preg_match($rx, $string); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment