Skip to content

Commit

Permalink
Fixed PCRE backtrace limit error
Browse files Browse the repository at this point in the history
  • Loading branch information
kukulich committed Jun 13, 2017
1 parent 9dd34f7 commit c91c4d0
Show file tree
Hide file tree
Showing 4 changed files with 222 additions and 3 deletions.
4 changes: 2 additions & 2 deletions Jyxo/Html.php
Original file line number Diff line number Diff line change
Expand Up @@ -580,8 +580,8 @@ public static function toText(string $html): string
*/
private static function linkToText(string $text): string
{
return preg_replace_callback('~<a\\s+(?:[^>]+\\s+)*href\\s*=\\s*"([^"]+)"(?:\\s+[^>]*)?>(.+?)</a>~is', function($matches) {
$url = trim($matches[1]);
return preg_replace_callback('~(<a\\s+[^>]*>)(.+?)</a>~is', function($matches) {
$url = preg_match('~\\shref="([^"]+)"~i', $matches[1], $submatches) ? trim($submatches[1]) : '';
$content = $matches[2];
$clearContent = trim(strip_tags($content));

Expand Down
2 changes: 1 addition & 1 deletion tests/Jyxo/HtmlTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@ public function testLinkFromText()
*/
public function testToText()
{
$testCount = 6;
$testCount = 7;

for ($i = 1; $i <= $testCount; $i++) {
$this->assertStringEqualsFile(
Expand Down
13 changes: 13 additions & 0 deletions tests/files/html/totext-7-expected.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@


200 KREDITOV NA LETNÚ DOVOLENKU

Hezký den!

Všimli sme si, že odmeny vo výške 2% z vašich mesačných nákupov, ktoré dostávate späť, sú v priemere iba 18 kreditov každý mesiac. Áno, tak málo. Toto zistenie nás priviedlo k tomu, že tieto odmeny zatiaľ rušíme. Ale za to vám vymyslíme niečo oveľa lepšie!

200 kreditov na letný pobyt

Neustále sa vás snažíme inšpirovať. Preto dávame zbohom kreditovým omrvinkám a namiesto toho môžete hneď teraz získať 200 kreditov <https://www.zlavomat.sk/kredity/pripocitane-z-importu/811?utm_medium=email&utm_source=info&utm_campaign=06-05-zrusenie-odmien2> na cestovateľské zážitky na Slovensku.

Pripíšte si 200 kreditov na cestovanie <https://www.zlavomat.sk/kredity/pripocitane-z-importu/811?utm_medium=email&utm_source=info&utm_campaign=06-05-zrusenie-odmien2>
206 changes: 206 additions & 0 deletions tests/files/html/totext-7.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,206 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office">

<head>
<!--[if gte mso 9]> <xml> <o:OfficeDocumentSettings> <o:AllowPNG/> <o:PixelsPerInch>96/o:PixelsPerInch> /o:OfficeDocumentSettings> </xml> <![endif]-->
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<style type="text/css">
#outlook a {
padding: 0
}
.ReadMsgBody {
width: 100%
}
.ExternalClass {
width: 100%
}
body {
width: 100% !important;
margin: 0;
padding: 0;
-webkit-text-size-adjust: 100%;
-ms-text-size-adjust: 100%
}
table {
border-spacing: 0
}
table td {
border-collapse: collapse
}
.header-background {
width: 100%
}
.background {
height: 100% !important;
margin: 0;
padding: 0;
width: 100% !important
}
@media screen and (max-width: 600px) {
.mobile-only {
display: block !important
}
.desktop-only {
display: none !important
}
table[class="container"],
table[class="header"] {
width: 100% !important
}
.header__content {
border-top: 1px solid #e3e4e6;
padding: 32px 0 16px 0 !important;
text-align: center !important
}
.container__content {
padding: 0 16px !important
}
.section-container-wrapper {
padding: 0 !important
}
.section-container {
width: 100% !important;
padding: 0 !important;
-moz-box-sizing: border-box !important;
-webkit-box-sizing: border-box !important;
box-sizing: border-box !important;
border-radius: 0 !important;
border: 0 !important;
border-top: 1px solid #e3e4e6 !important;
border-bottom: 1px solid #e3e4e6 !important;
background-color: #fff !important
}
.section-container__content {
padding: 0 16px 32px 16px !important
}
.header-text {
margin-top: 16px !important;
margin-bottom: 8px !important;
line-height: 24px !important;
font-size: 18px !important;
text-align: center !important
}
.header-text__subtitle {
text-align: center !important;
font-size: 16px !important
}
.message {
margin: 0 0 32px 0 !important
}
.product-custom__name {
margin: 12px 0 0 0 !important;
line-height: 24px !important;
font-size: 18px !important
}
.product-custom__info {
margin: 6px 0 0 0 !important
}
.product-custom__rating {
margin: 16px 0 0 0 !important
}
.category-button-wrapper {
margin-top: 16px !important
}
.category-button {
margin-bottom: 10px
}
.campaign-custom__name {
font-size: 18px !important;
line-height: 24px !important
}
.campaign-custom__subtitle {
font-size: 13px !important;
line-height: 20px !important
}
}
</style>
<!--[if gte mso 9]> <style type="text/css">body{width:100% !important;margin:0;padding:0}table{border-collapse:collapse;mso-table-lspace:0;mso-table-rspace:0}img{-ms-interpolation-mode:bicubic}td{font-family:sans-serif}a{color:#228dc3;text-decoration:none}ul{margin-left:40px !important}.mobile-only{display:none}.message{background:#fff !important}.section-container-wrapper{padding:0 0 16px 0}.section-container{background:#fff}.button{color:#000;background-color:transparent !important;text-decoration:none !important}.button-secondary{color:#000;background-color:transparent !important}.button--full{display:block !important}.product-custom__name{margin:10px 0 0 0}.product-custom__name-link{color:#000}.product-custom__info{margin:4px 0 0 0;color:#78787d}.product-custom__price{margin:6px 0 0 0 !important;color:#1c8119}.product-custom__rating{background:transparent !important}</style> <![endif]-->
<style type="text/css">
@media screen and (max-width: 600px) {
body {
font-size: 16px !important;
line-height: 24px !important
}
.section-container {
background: transparent !important;
border: 0 !important
}
h2 {
font-size: 24px !important;
line-height: 30px !important
}
h3 {
font-size: 18px !important;
line-height: 24px !important
}
.citation {
max-width: 100% !important
}
.custom-logo {
padding: 32px 0 16px 0 !important
}
.custom-module {
padding: 0 0 24px 0 !important
}
.campaign-custom__name,
.category-custom__name,
.tag-custom__name,
.button-category,
.button-tag {
font-size: 18px !important;
line-height: 24px !important
}
.campaign-custom__subtitle {
font-size: 13px !important;
line-height: 20px !important
}
}
</style>
<!--[if gte mso 9]> <style type="text/css">.section-container{background:transparent !important;border:0 !important}p a{color:#7436ab;text-decoration:underline}.product-custom__name-link,.campaign-custom__name-link,.category-custom__name-link,.tag-custom__name-link{color:#7436ab}.campaign-custom,.category-custom,.tag-custom{background:transparent !important;padding:0 !important;text-align:center !important}.campaign-custom__border,.category-custom__border,.tag-custom__border{background:transparent !important;border:0 !important}</style> <![endif]-->
</head>

<body leftmargin="0" marginwidth="0" topmargin="0" marginheight="0" offset="0" class="bruise" style="width:100% !important;margin:0;padding:0;line-height:26px;font-size:18px;font-family:'Segoe UI','Helvetica Neue',Helvetica,Arial,sans-serif;-webkit-text-size-adjust:none;-ms-text-size-adjust:100%;color:#000;background-color:#f0efff">
<table border="0" cellpadding="0" cellspacing="0" width="100%" class="background" style="width:100% !important;margin:0;padding:0;border-spacing:0;height:100% !important;background-color:#f0efff;color:#000">
<tr style="margin:0;padding:0">
<td align="center" valign="top" class="section-container-wrapper" style="border-collapse:collapse;margin:0;padding:0 8px">
<!--[if mso]><table cellpadding="0" cellspacing="0" border="0" width="600" style="width:600px;margin:0;padding:0;border-spacing:0"><tr style="margin:0;padding:0"><td style="border-collapse:collapse;margin:0;padding:16px 0"><![endif]-->
<table border="0" cellpadding="0" cellspacing="0" width="600" class="section-container" style="width:100%;margin:0;padding:0;border-spacing:0;max-width:600px;margin-bottom:0;border-radius:4px;background-color:#fff;border:0;background:transparent">
<tr style="margin:0;padding:0">
<td align="left" valign="top" class="section-container__content" style="border-collapse:collapse;margin:0;padding:0">
<!--[if mso]><table cellpadding="0" cellspacing="0" border="0" style="width:100%;margin:0;padding:0;border-spacing:0"><tr style="margin:0;padding:0"><td style="border-collapse:collapse;margin:0;padding:16px 0"><![endif]-->
<table cellpadding="0" cellspacing="0" border="0" class="header" style="width:100%;margin:0;padding:0;border-spacing:0;max-width:600px;background-color:transparent">
<td align="left" valign="top" class="custom-logo" style="border-collapse:collapse;margin:0;padding:56px 0 16px 0">
<a href="https://zlavomat.local/bratislava?utm_campaign=06-05-zrusenie-odmien2&amp;utm_medium=email&amp;utm_source=info" style="color:#0074c1 !important;text-decoration:none !important"><img id="logo" srcset="https://zlavomat.local/static/images/logo/logo-bruise-z.svg" alt="Zlavomat.sk" width="128" style="border:0;width:100%;height:auto;line-height:100%;outline:0;text-decoration:none;max-width:128px" src="https://zlavomat.local/static/images/logo/logo-bruise-z.png">
</a>
</td>
</table>
<!--[if mso]></td></tr></table><![endif]-->
<!--[if mso]><table cellpadding="0" cellspacing="0" border="0" style="width:100%;margin:0;padding:0;border-spacing:0"><tr style="margin:0;padding:0"><td style="border-collapse:collapse;margin:0;padding:16px 0"><![endif]-->
<table cellpadding="0" cellspacing="0" border="0" style="width:100%;margin:0;padding:0;border-spacing:0">
<tr style="margin:0;padding:0">
<td align="left" valign="top" style="border-collapse:collapse;margin:0;padding:0">
<h2 style="margin:16px 0 40px 0;color:#000;font-size:32px;font-weight:600;line-height:40px"> 200 kreditov na letnú dovolenku </h2>
<p class="custom-salutation" style="margin:16px 0 0 0">Hezký den!</p>
</td>
</tr>
</table>
<table cellpadding="0" cellspacing="0" border="0" style="width:100%;margin:0;padding:0;border-spacing:0">
<tr style="margin:0;padding:0">
<td align="left" valign="top" class="custom-module" style="border-collapse:collapse;margin:0;padding:0 0 40px 0">
<p style="margin:16px 0"> Všimli sme si, že odmeny vo výške 2% z vašich mesačných nákupov, ktoré dostávate&nbsp;späť, sú v priemere iba 18 kreditov každý mesiac. Áno, tak málo. Toto zistenie nás priviedlo k tomu, že tieto odmeny zatiaľ rušíme. Ale za to vám vymyslíme niečo oveľa lepšie! </p>
<h3 style="color:#000;font-size:24px;font-weight:600;line-height:30px"> 200 kreditov na letný pobyt </h3>
<p style="margin:16px 0"> Neustále sa vás snažíme inšpirovať. Preto dávame zbohom kreditovým omrvinkám a namiesto toho môžete hneď <a href="https://www.zlavomat.sk/kredity/pripocitane-z-importu/811?utm_medium=email&utm_source=info&utm_campaign=06-05-zrusenie-odmien2" target="_blank" rel="noopener" style="color:#7436ab !important;text-decoration:underline !important">teraz získať 200 kreditov</a> na cestovateľské zážitky na Slovensku. </p>
<p style="margin:16px 0"> <a href="https://www.zlavomat.sk/kredity/pripocitane-z-importu/811?utm_medium=email&utm_source=info&utm_campaign=06-05-zrusenie-odmien2" class="button button--full" target="_blank" rel="noopener" style="color:#fff !important;text-decoration:none !important;display:block;vertical-align:top;padding:16px 52px;line-height:22px;border:1px solid #5d2b89;border-radius:4px;background:#0074c1;-webkit-box-shadow:0 1px 0 #5d2b89;box-shadow:0 1px 0 #5d2b89;font-size:16px;font-weight:500;text-align:center;background-color:#7436ab">Pripíšte si 200 kreditov na cestovanie</a> </p>
</td>
</tr>
</table>
<!--[if mso]></td></tr></table><![endif]-->
</td>
</tr>
</table>
</td>
</tr>
</table>
</body>

</html>

0 comments on commit c91c4d0

Please sign in to comment.