8000 [yaml] Inline::parseQuotedScalar() causes stack overflow in Windows is field contains a lot of double quotes · Issue #14722 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

[yaml] Inline::parseQuotedScalar() causes stack overflow in Windows is field contains a lot of double quotes #14722

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
mahagr opened this issue May 22, 2015 · 13 comments

Comments

@mahagr
Copy link
mahagr commented May 22, 2015

The following regexp uses a lot of recursion every time the content has a lot of double quotes:

(?:"([^"\\\\]*(?:\\\\.[^"\\\\]*)*)"

Basically it is causing a crash in windows due to stack overflow on large inputs (~20k of escaped html in the field).

@stof
Copy link
Member
stof commented May 22, 2015

We should try to use possessive quantifiers if it is possible.

@stof
Copy link
Member
stof commented May 22, 2015

@mahagr can you provide the file which triggered the issue for you to help reproducing the issue ?

@mahagr
Copy link
Author
mahagr commented May 22, 2015

I'm just trying to debug it myself, possessive quantifiers seem to need 3-5 times as many steps to get the result.

I'm using the following html code as my example:

"<div class=\"g-grid\">\n <div class=\"g-block box4\">\n <div class=\"g-content\">\n \t<h2 class=\"nomarginall g-uppercase\">Text Styles</h2>\n </div>\n\t</div>\n</div>\n<div class=\"g-grid\">\n <div class=\"g-block\">\n <div class=\"g-content\">\n <h2 class=\"nomarginall\">Headings</h2>\n <p>All HTML headings, <code>&lt;h1&gt;</code> through <code>&lt;h6&gt;</code> are available.</p>\n <div>\n <h1>h1. Heading 1</h1>\n\t\t\t\t<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec sit amet nibh. Vivamus non arcu.</p>\n <h2>h2. Heading 2</h2>\n\t\t\t\t<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec sit amet nibh. Vivamus non arcu.</p>\n <h3>h3. Heading 3</h3>\n\t\t\t\t<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec sit amet nibh. Vivamus non arcu.</p>\n <h4>h4. Heading 4</h4>\n <h5>h5. Heading 5</h5>\n <h6>h6. Heading 6</h6>\n </div>\n </div>\n </div>\n\n <div class=\"g-block\">\n <div class=\"g-content\">\n <h2 class=\"nomarginall\">Emphasis</h2>\n <h4><code>&lt;em&gt;</code></h4>\n <p>For emphasizing a snippet of text with <em>stress</em></p>\n <p>The following snippet of text is <em>rendered as italicized text</em>.</p>\n <pre class=\"prettyprint\">&lt;em&gt;rendered as italicized text&lt;/em&gt;</pre>\n <h4><code>&lt;strong&gt;</code></h4>\n <p>For emphasizing a snippet of text with <strong>important</strong></p>\n <p>The following snippet of text is <strong>rendered as bold text</strong>.</p>\n <pre class=\"prettyprint\">&lt;strong&gt;rendered as bold text&lt;/strong&gt;</pre>\n <h4><code>&lt;small&gt;</code></h4>\n <p>For de-emphasizing inline or blocks of text, <small>use the small tag.</small></p>\n <p><small>This line of text is meant to be treated as fine print.</small></p>\n </div>\n </div>\n</div>\n\n<div class=\"g-grid\">\n <div class=\"g-block\">\n <div class=\"g-content\">\n <h2 class=\"nomarginall\">Abbreviations</h2>\n <p>Stylized implementation of HTML's <code>&lt;abbr&gt;</code> element for abbreviations and acronyms to show the expanded version on hover. Abbreviations with a <code>title</code> attribute have a light dotted bottom border and a help cursor on hover, providing additional context on hover.</p>\n\n <h4><code>&lt;abbr&gt;</code></h4>\n <p>For expanded text on long hover of an abbreviation, include the <code>title</code> attribute.</p>\n <div class=\"gantry-example\">\n <p>An abbreviation of the word attribute is <abbr title=\"attribute\">attr</abbr>.</p>\n </div>\n <pre class=\"prettyprint\">&lt;abbr title=\"attribute\"&gt;attr&lt;/abbr&gt;</pre>\n </div>\n </div>\n <div class=\"g-block\">\n <div class=\"g-content\">\n <h2 class=\"nomarginall\">Addresses</h2>\n <p>Stylized implementation of HTML's element to present contact information for the nearest ancestor or the entire body of work.</p>\n <h4><code>&lt;address&gt;</code></h4>\n <p>Preserve formatting by ending all lines with <code>&lt;br&gt;</code>.</p>\n <address>\n <strong>Twitter, Inc.</strong><br/>\n 795 Folsom Ave, Suite 600<br/>\n San Francisco, CA 94107<br/><abbr title=\"Phone\">P:</abbr> (123) 456-7890\n </address>\n <address>\n <strong>Full Name</strong><br/><a href=\"mailto:#\"><span id=\"cloak45941\">This email address is being protected from spambots. You need JavaScript enabled to view it.</span><script type=\"text/javascript\">\n //<!--\n document.getElementById('cloak45941').innerHTML = '';\n var prefix = '&#109;a' + 'i&#108;' + '&#116;o';\n var path = 'hr' + 'ef' + '=';\n var addy45941 = 'f&#105;rst.l&#97;st' + '&#64;';\n addy45941 = addy45941 + 'gm&#97;&#105;l' + '&#46;' + 'c&#111;m';\n document.getElementById('cloak45941').innerHTML += '<a ' + path + '\\'' + prefix + ':' + addy45941 + '\\'>' +addy45941+'<\\/a>';\n //-->\n </script></a>\n </address>\n<pre class=\"prettyprint linenums\">\n&lt;address&gt;\n&lt;strong&gt;Twitter, Inc.&lt;/strong&gt;&lt;br&gt;\n795 Folsom Ave, Suite 600&lt;br&gt;\nSan Francisco, CA 94107&lt;br&gt;\n&lt;abbr title=\"Phone\"&gt;P:&lt;/abbr&gt; (123) 456-7890\n&lt;/address&gt;\n&lt;address&gt;\n&lt;strong&gt;Full Name&lt;/strong&gt;&lt;br&gt;\n&lt;a href=\"mailto:#\"&gt;first.last@gmail.com&lt;/a&gt;\n&lt;/address&gt;\n</pre>\n </div>\n </div>\n</div>\n\n<div class=\"g-grid\">\n <div class=\"g-block\">\n <div class=\"g-content\">\n\t\t <div class=\"g-block box4 nomarginall\">\n\t\t <div class=\"g-content\">\n\t\t \t<h2 class=\"nomarginall g-uppercase\">Notice Styles</h2>\n\t\t </div>\n\t\t\t</div>\n <p class=\"success\">Nullam quis risus eget urna mollis ornare vel eu leo. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus.</p>\n <pre class=\"prettyprint\">&lt;p class=\"success\"&gt;...&lt;/p&gt;</pre>\n <p class=\"info\">Nullam quis risus eget urna mollis ornare vel eu leo. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus.</p>\n <pre class=\"prettyprint\">&lt;p class=\"info\"&gt;...&lt;/p&gt;</pre>\n <p class=\"warning\">Nullam quis risus eget urna mollis ornare vel eu leo. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus.</p>\n <pre class=\"prettyprint\">&lt;p class=\"warning\"&gt;...&lt;/p&gt;</pre>\n <p class=\"error\">Nullam quis risus eget urna mollis ornare vel eu leo. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus.</p>\n <pre class=\"prettyprint\">&lt;p class=\"error\"&gt;...&lt;/p&gt;</pre>\n </div>\n </div>\n</div>\n\n<div class=\"g-grid\">\n <div class=\"g-block\">\n <div class=\"g-content\">\n\t\t <div class=\"g-block box4 nomarginall\">\n\t\t <div class=\"g-content\">\n\t\t \t<h2 class=\"nomarginall g-uppercase\">Blockquotes</h2>\n\t\t </div>\n\t\t\t</div>\n <p>For quoting blocks of content from another source within your document.</p>\n <h3>Default blockquote</h3>\n <p>Wrap <code>&lt;blockquote&gt;</code> around any <abbr title=\"HyperText Markup Language\">HTML</abbr> as the quote. For straight quotes we recommend a <code>&lt;p&gt;</code>.</p>\n <blockquote>\n <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer posuere erat a ante.</p>\n </blockquote>\n<pre class=\"prettyprint linenums\">&lt;blockquote&gt;\n&lt;p&gt;Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer posuere erat a ante.&lt;/p&gt;\n&lt;/blockquote&gt;</pre>\n\n <h3>Blockquote options</h3>\n <span>Style and content changes for simple variations on a standard blockquote.</span><br/>\n\n <h4>Naming a source</h4>\n <p>Add <code>&lt;small&gt;</code> tag for identifying the source. Wrap the name of the source work in <code>&lt;cite&gt;</code>.</p>\n <blockquote>\n <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer posuere erat a ante.</p>\n <small>Someone famous in <cite title=\"Source Title\">Source Title</cite></small>\n </blockquote>\n<pre class=\"prettyprint linenums\">&lt;blockquote&gt;\n&lt;p&gt;Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer posuere erat a ante.&lt;/p&gt;\n&lt;small&gt;Someone famous &lt;cite title=\"Source Title\"&gt;Source Title&lt;/cite&gt;&lt;/small&gt;\n&lt;/blockquote&gt;</pre>\n </div>\n </div>\n</div>\n\n<div class=\"g-grid\">\n <div class=\"g-block box4\">\n <div class=\"g-content\">\n \t<h2 class=\"nomarginall g-uppercase\">Code</h2>\n </div>\n\t</div>\n</div>\n<div class=\"g-grid\">\n <div class=\"g-block\">\n <div class=\"g-content\">\n <h4 class=\"nomarginall\">Inline</h2>\n <p>Wrap inline snippets of code with <code>&lt;code&gt;</code>.</p>\n For example, <code>&lt;section&gt;</code> should be wrapped as inline.\n <pre class=\"prettyprint linenums\">For example, &lt;code&gt;&lt;section&gt;&lt;/code&gt; should be wrapped as inline.</pre>\n <p><strong>Note:</strong> Be sure to keep code within <code>&lt;pre&gt;</code> tags as close to the left as possible; it will render all tabs.</p>\n </div>\n </div>\n <div class=\"g-block\">\n <div class=\"g-content\">\n <h4 class=\"nomarginall\">Basic block</h2>\n <p>Use <code>&lt;pre&gt;</code> for multiple lines of code. Be sure to escape any angle brackets in the code for proper rendering.</p>\n <pre>&lt;p&gt;Sample text here...&lt;/p&gt;</pre>\n<pre class=\"prettyprint linenums\" style=\"margin-bottom: 9px;\">&lt;pre&gt;\n&amp;lt;p&amp;gt;Sample text here...&amp;lt;/p&amp;gt;\n&lt;/pre&gt;</pre>\n </div>\n </div>\n</div>\n\n<div class=\"g-grid\">\n <div class=\"g-block\">\n <div class=\"g-content\">\n\t\t <div class=\"g-block box4 nomarginall\">\n\t\t <div class=\"g-content\">\n\t\t \t<h2 class=\"nomarginall g-uppercase\">Tables</h2>\n\t\t </div>\n\t\t\t</div>\n\t\t\t<br />\n <table>\n <thead><tr>\n <th>#</th>\n <th>First Name</th>\n <th>Last Name</th>\n <th>Username</th>\n </tr></thead>\n <tbody>\n <tr>\n <td>1</td>\n <td>Mark</td>\n <td>Otto</td>\n <td>@mdo</td>\n </tr>\n <tr>\n <td>2</td>\n <td>Jacob</td>\n <td>Thornton</td>\n <td>@fat</td>\n </tr>\n <tr>\n <td>3</td>\n <td>Larry</td>\n <td>the Bird</td>\n <td>@twitter</td>\n </tr>\n </tbody>\n </table>\n<pre class=\"prettyprint linenums\">&lt;table class=\"table\"&gt;\n…\n&lt;/table&gt;</pre>\n </div>\n </div>\n</div>\n\n<div class=\"g-grid\">\n <div class=\"g-block\">\n <div class=\"g-content\">\n\t\t <div class=\"g-block box4 nomarginall\">\n\t\t <div class=\"g-content\">\n\t\t \t<h2 class=\"nomarginall g-uppercase\">Forms</h2>\n\t\t </div>\n\t\t\t</div>\n <p>Individual form controls receive styling, but without any required base class on the <code>&lt;form&gt;</code> or large changes in markup. Results in stacked, left-aligned labels on top of form controls.</p>\n <form>\n <fieldset>\n <legend>Legend</legend>\n <label>Label name</label>\n <input type=\"text\" placeholder=\"Type something…\"/><span class=\"help-block\">Example block-level help text here.</span>\n <label class=\"checkbox\">\n <input type=\"checkbox\"/> Check me out\n </label>\n <button type=\"submit\" class=\"btn\">Submit</button>\n </fieldset>\n </form>\n\n<pre class=\"prettyprint linenums\">&lt;form&gt;\n&lt;legend&gt;Legend&lt;/legend&gt;\n&lt;label&gt;Label name&lt;/label&gt;\n&lt;input type=\"text\" placeholder=\"Type something…\"&gt;\n&lt;span class=\"help-block\"&gt;Example block-level help text here.&lt;/span&gt;\n&lt;label class=\"checkbox\"&gt;\n&lt;input type=\"checkbox\"&gt; Check me out\n&lt;/label&gt;\n&lt;button type=\"submit\" class=\"btn\"&gt;Submit&lt;/button&gt;\n&lt;/form&gt;</pre>\n </div>\n </div>\n</div>\n\n<div class=\"g-grid\">\n <div class=\"g-block\">\n <div class=\"g-content\">\n <h4>Inputs</h3>\n <p>Most common form control, text-based input fields. Includes support for all HTML5 types: text, password, datetime, datetime-local, date, month, time, week, number, email, url, search, tel, and color.</p>\n <p>Requires the use of a specified <code>type</code> at all times.</p>\n <form class=\"form-inline\">\n <input type=\"text\" placeholder=\"Text input\"/>\n </form>\n <pre class=\"prettyprint linenums\">&lt;input type=\"text\" placeholder=\"Text input\"&gt;</pre>\n\n <h4>Textarea</h3>\n <p>Form control which supports multiple lines of text. Change <code>row</code> attribute as necessary.</p>\n <form class=\"form-inline\">\n <textarea rows=\"3\"></textarea>\n </form>\n <pre class=\"prettyprint linenums\">&lt;textarea rows=\"3\"&gt;&lt;/textarea&gt;</pre>\n\n <h4>Checkboxes and radios</h3>\n <p>Checkboxes are for selecting one or several options in a list while radios are for selecting one option from many.</p>\n <h4>Default (stacked)</h4>\n <form>\n <label class=\"checkbox\">\n <input type=\"checkbox\" value=\"\"/>\n Option one is this and that—be sure to include why it's great\n </label>\n <br/><label class=\"radio\">\n <input type=\"radio\" name=\"optionsRadios\" id=\"optionsRadios1\" value=\"option1\" checked>\n Option one is this and that—be sure to include why it's great\n </label>\n <label class=\"radio\">\n <input type=\"radio\" name=\"optionsRadios\" id=\"optionsRadios2\" value=\"option2\"/>\n Option two can be something else and selecting it will deselect option one\n </label>\n </form>\n<pre class=\"prettyprint linenums\">&lt;label class=\"checkbox\"&gt;\n&lt;input type=\"checkbox\" value=\"\"&gt;\nOption one is this and that—be sure to include why it's great\n&lt;/label&gt;\n\n&lt;label class=\"radio\"&gt;\n&lt;input type=\"radio\" name=\"optionsRadios\" id=\"optionsRadios1\" value=\"option1\" checked&gt;\nOption one is this and that—be sure to include why it's great\n&lt;/label&gt;\n&lt;label class=\"radio\"&gt;\n&lt;input type=\"radio\" name=\"optionsRadios\" id=\"optionsRadios2\" value=\"option2\"&gt;\nOption two can be something else and selecting it will deselect option one\n&lt;/label&gt;</pre>\n\n <h4>Inline checkboxes</h4>\n <p>Add the <code>.inline</code> class to a series of checkboxes or radios for controls appear on the same line.</p>\n <form>\n <label class=\"checkbox inline\">\n <input type=\"checkbox\" id=\"inlineCheckbox1\" value=\"option1\"/> 1\n </label>\n <label class=\"checkbox inline\">\n <input type=\"checkbox\" id=\"inlineCheckbox2\" value=\"option2\"/> 2\n </label>\n <label class=\"checkbox inline\">\n <input type=\"checkbox\" id=\"inlineCheckbox3\" value=\"option3\"/> 3\n </label>\n </form>\n<pre class=\"prettyprint linenums\">&lt;label class=\"checkbox inline\"&gt;\n&lt;input type=\"checkbox\" id=\"inlineCheckbox1\" value=\"option1\"&gt; 1\n&lt;/label&gt;\n&lt;label class=\"checkbox inline\"&gt;\n&lt;input type=\"checkbox\" id=\"inlineCheckbox2\" value=\"option2\"&gt; 2\n&lt;/label&gt;\n&lt;label class=\"checkbox inline\"&gt;\n&lt;input type=\"checkbox\" id=\"inlineCheckbox3\" value=\"option3\"&gt; 3\n&lt;/label&gt;</pre>\n\n <h4>Selects</h3>\n <p>Use the default option or specify a <code>multiple=\"multiple\"</code> to show multiple options at once.</p>\n <form>\n <select><option>1</option>\n <option>2</option>\n <option>3</option>\n <option>4</option>\n <option>5</option></select><br/><select multiple><option>1</option>\n <option>2</option>\n <option>3</option>\n <option>4</option>\n <option>5</option></select>\n </form>\n<pre class=\"prettyprint linenums\">&lt;select&gt;\n&lt;option&gt;1&lt;/option&gt;\n&lt;option&gt;2&lt;/option&gt;\n&lt;option&gt;3&lt;/option&gt;\n&lt;option&gt;4&lt;/option&gt;\n&lt;option&gt;5&lt;/option&gt;\n&lt;/select&gt;\n\n&lt;select multiple=\"multiple\"&gt;\n&lt;option&gt;1&lt;/option&gt;\n&lt;option&gt;2&lt;/option&gt;\n&lt;option&gt;3&lt;/option&gt;\n&lt;option&gt;4&lt;/option&gt;\n&lt;option&gt;5&lt;/option&gt;\n&lt;/select&gt;</pre>\n </div>\n </div>\n</div>\n\n<div class=\"g-grid\">\n <div class=\"g-block\">\n <div class=\"g-content\">\n\t\t <div class=\"g-block box4 nomarginall\">\n\t\t <div class=\"g-content\">\n\t\t \t<h2 class=\"nomarginall g-uppercase\">Buttons</h2>\n\t\t </div>\n\t\t\t</div>\n\t\t\t<br />\n <form>\n <a class=\"button\" href=\"#\">Link</a>\n <button class=\"button\" type=\"submit\">Button</button>\n <input class=\"button\" type=\"button\" value=\"Input\"/>\n <input class=\"button\" type=\"submit\" value=\"Submit\"/>\n </form>\n<pre class=\"prettyprint linenums\">&lt;a class=\"button\" href=\"\"&gt;Link&lt;/a&gt;\n&lt;button class=\"button\" type=\"submit\"&gt
8000
;Button&lt;/button&gt;\n&lt;input class=\"button\" type=\"button\" value=\"Input\"&gt;\n&lt;input class=\"button\" type=\"submit\" value=\"Submit\"&gt;</pre>\n </div>\n </div>\n</div>") at line 313 (near "html: "<div class=\"g-grid\">\n <div class=\"g-block box4\">\n <div class=\"g-content\">\n \t<h2 class=\"nomarginall g-uppercase\">Text Styles</h2>\n </div>\n\t</div>\n</div>\n<div class=\"g-grid\">\n <div class=\"g-block\">\n <div class=\"g-content\">\n <h2 class=\"nomarginall\">Headings</h2>\n <p>All HTML headings, <code>&lt;h1&gt;</code> through <code>&lt;h6&gt;</code> are available.</p>\n <div>\n <h1>h1. Heading 1</h1>\n\t\t\t\t<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec sit amet nibh. Vivamus non arcu.</p>\n <h2>h2. Heading 2</h2>\n\t\t\t\t<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec sit amet nibh. Vivamus non arcu.</p>\n <h3>h3. Heading 3</h3>\n\t\t\t\t<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec sit amet nibh. Vivamus non arcu.</p>\n <h4>h4. Heading 4</h4>\n <h5>h5. Heading 5</h5>\n <h6>h6. Heading 6</h6>\n </div>\n </div>\n </div>\n\n <div class=\"g-block\">\n <div class=\"g-content\">\n <h2 class=\"nomarginall\">Emphasis</h2>\n <h4><code>&lt;em&gt;</code></h4>\n <p>For emphasizing a snippet of text with <em>stress</em></p>\n <p>The following snippet of text is <em>rendered as italicized text</em>.</p>\n <pre class=\"prettyprint\">&lt;em&gt;rendered as italicized text&lt;/em&gt;</pre>\n <h4><code>&lt;strong&gt;</code></h4>\n <p>For emphasizing a snippet of text with <strong>important</strong></p>\n <p>The following snippet of text is <strong>rendered as bold text</strong>.</p>\n <pre class=\"prettyprint\">&lt;strong&gt;rendered as bold text&lt;/strong&gt;</pre>\n <h4><code>&lt;small&gt;</code></h4>\n <p>For de-emphasizing inline or blocks of text, <small>use the small tag.</small></p>\n <p><small>This line of text is meant to be treated as fine print.</small></p>\n </div>\n </div>\n</div>\n\n<div class=\"g-grid\">\n <div class=\"g-block\">\n <div class=\"g-content\">\n <h2 class=\"nomarginall\">Abbreviations</h2>\n <p>Stylized implementation of HTML's <code>&lt;abbr&gt;</code> element for abbreviations and acronyms to show the expanded version on hover. Abbreviations with a <code>title</code> attribute have a light dotted bottom border and a help cursor on hover, providing additional context on hover.</p>\n\n <h4><code>&lt;abbr&gt;</code></h4>\n <p>For expanded text on long hover of an abbreviation, include the <code>title</code> attribute.</p>\n <div class=\"gantry-example\">\n <p>An abbreviation of the word attribute is <abbr title=\"attribute\">attr</abbr>.</p>\n </div>\n <pre class=\"prettyprint\">&lt;abbr title=\"attribute\"&gt;attr&lt;/abbr&gt;</pre>\n </div>\n </div>\n <div class=\"g-block\">\n <div class=\"g-content\">\n <h2 class=\"nomarginall\">Addresses</h2>\n <p>Stylized implementation of HTML's element to present contact information for the nearest ancestor or the entire body of work.</p>\n <h4><code>&lt;address&gt;</code></h4>\n <p>Preserve formatting by ending all lines with <code>&lt;br&gt;</code>.</p>\n <address>\n <strong>Twitter, Inc.</strong><br/>\n 795 Folsom Ave, Suite 600<br/>\n San Francisco, CA 94107<br/><abbr title=\"Phone\">P:</abbr> (123) 456-7890\n </address>\n <address>\n <strong>Full Name</strong><br/><a href=\"mailto:#\"><span id=\"cloak45941\">This email address is being protected from spambots. You need JavaScript enabled to view it.</span><script type=\"text/javascript\">\n //<!--\n document.getElementById('cloak45941').innerHTML = '';\n var prefix = '&#109;a' + 'i&#108;' + '&#116;o';\n var path = 'hr' + 'ef' + '=';\n var addy45941 = 'f&#105;rst.l&#97;st' + '&#64;';\n addy45941 = addy45941 + 'gm&#97;&#105;l' + '&#46;' + 'c&#111;m';\n document.getElementById('cloak45941').innerHTML += '<a ' + path + '\\'' + prefix + ':' + addy45941 + '\\'>' +addy45941+'<\\/a>';\n //-->\n </script></a>\n </address>\n<pre class=\"prettyprint linenums\">\n&lt;address&gt;\n&lt;strong&gt;Twitter, Inc.&lt;/strong&gt;&lt;br&gt;\n795 Folsom Ave, Suite 600&lt;br&gt;\nSan Francisco, CA 94107&lt;br&gt;\n&lt;abbr title=\"Phone\"&gt;P:&lt;/abbr&gt; (123) 456-7890\n&lt;/address&gt;\n&lt;address&gt;\n&lt;strong&gt;Full Name&lt;/strong&gt;&lt;br&gt;\n&lt;a href=\"mailto:#\"&gt;first.last@gmail.com&lt;/a&gt;\n&lt;/address&gt;\n</pre>\n </div>\n </div>\n</div>\n\n<div class=\"g-grid\">\n <div class=\"g-block\">\n <div class=\"g-content\">\n\t\t <div class=\"g-block box4 nomarginall\">\n\t\t <div class=\"g-content\">\n\t\t \t<h2 class=\"nomarginall g-uppercase\">Notice Styles</h2>\n\t\t </div>\n\t\t\t</div>\n <p class=\"success\">Nullam quis risus eget urna mollis ornare vel eu leo. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus.</p>\n <pre class=\"prettyprint\">&lt;p class=\"success\"&gt;...&lt;/p&gt;</pre>\n <p class=\"info\">Nullam quis risus eget urna mollis ornare vel eu leo. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus.</p>\n <pre class=\"prettyprint\">&lt;p class=\"info\"&gt;...&lt;/p&gt;</pre>\n <p class=\"warning\">Nullam quis risus eget urna mollis ornare vel eu leo. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus.</p>\n <pre class=\"prettyprint\">&lt;p class=\"warning\"&gt;...&lt;/p&gt;</pre>\n <p class=\"error\">Nullam quis risus eget urna mollis ornare vel eu leo. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus.</p>\n <pre class=\"prettyprint\">&lt;p class=\"error\"&gt;...&lt;/p&gt;</pre>\n </div>\n </div>\n</div>\n\n<div class=\"g-grid\">\n <div class=\"g-block\">\n <div class=\"g-content\">\n\t\t <div class=\"g-block box4 nomarginall\">\n\t\t <div class=\"g-content\">\n\t\t \t<h2 class=\"nomarginall g-uppercase\">Blockquotes</h2>\n\t\t </div>\n\t\t\t</div>\n <p>For quoting blocks of content from another source within your document.</p>\n <h3>Default blockquote</h3>\n <p>Wrap <code>&lt;blockquote&gt;</code> around any <abbr title=\"HyperText Markup Language\">HTML</abbr> as the quote. For straight quotes we recommend a <code>&lt;p&gt;</code>.</p>\n <blockquote>\n <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer posuere erat a ante.</p>\n </blockquote>\n<pre class=\"prettyprint linenums\">&lt;blockquote&gt;\n&lt;p&gt;Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer posuere erat a ante.&lt;/p&gt;\n&lt;/blockquote&gt;</pre>\n\n <h3>Blockquote options</h3>\n <span>Style and content changes for simple variations on a standard blockquote.</span><br/>\n\n <h4>Naming a source</h4>\n <p>Add <code>&lt;small&gt;</code> tag for identifying the source. Wrap the name of the source work in <code>&lt;cite&gt;</code>.</p>\n <blockquote>\n <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer posuere erat a ante.</p>\n <small>Someone famous in <cite title=\"Source Title\">Source Title</cite></small>\n </blockquote>\n<pre class=\"prettyprint linenums\">&lt;blockquote&gt;\n&lt;p&gt;Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer posuere erat a ante.&lt;/p&gt;\n&lt;small&gt;Someone famous &lt;cite title=\"Source Title\"&gt;Source Title&lt;/cite&gt;&lt;/small&gt;\n&lt;/blockquote&gt;</pre>\n </div>\n </div>\n</div>\n\n<div class=\"g-grid\">\n <div class=\"g-block box4\">\n <div class=\"g-content\">\n \t<h2 class=\"nomarginall g-uppercase\">Code</h2>\n </div>\n\t</div>\n</div>\n<div class=\"g-grid\">\n <div class=\"g-block\">\n <div class=\"g-content\">\n <h4 class=\"nomarginall\">Inline</h2>\n <p>Wrap inline snippets of code with <code>&lt;code&gt;</code>.</p>\n For example, <code>&lt;section&gt;</code> should be wrapped as inline.\n <pre class=\"prettyprint linenums\">For example, &lt;code&gt;&lt;section&gt;&lt;/code&gt; should be wrapped as inline.</pre>\n <p><strong>Note:</strong> Be sure to keep code within <code>&lt;pre&gt;</code> tags as close to the left as possible; it will render all tabs.</p>\n </div>\n </div>\n <div class=\"g-block\">\n <div class=\"g-content\">\n <h4 class=\"nomarginall\">Basic block</h2>\n <p>Use <code>&lt;pre&gt;</code> for multiple lines of code. Be sure to escape any angle brackets in the code for proper rendering.</p>\n <pre>&lt;p&gt;Sample text here...&lt;/p&gt;</pre>\n<pre class=\"prettyprint linenums\" style=\"margin-bottom: 9px;\">&lt;pre&gt;\n&amp;lt;p&amp;gt;Sample text here...&amp;lt;/p&amp;gt;\n&lt;/pre&gt;</pre>\n </div>\n </div>\n</div>\n\n<div class=\"g-grid\">\n <div class=\"g-block\">\n <div class=\"g-content\">\n\t\t <div class=\"g-block box4 nomarginall\">\n\t\t <div class=\"g-content\">\n\t\t \t<h2 class=\"nomarginall g-uppercase\">Tables</h2>\n\t\t </div>\n\t\t\t</div>\n\t\t\t<br />\n <table>\n <thead><tr>\n <th>#</th>\n <th>First Name</th>\n <th>Last Name</th>\n <th>Username</th>\n </tr></thead>\n <tbody>\n <tr>\n <td>1</td>\n <td>Mark</td>\n <td>Otto</td>\n <td>@mdo</td>\n </tr>\n <tr>\n <td>2</td>\n <td>Jacob</td>\n <td>Thornton</td>\n <td>@fat</td>\n </tr>\n <tr>\n <td>3</td>\n <td>Larry</td>\n <td>the Bird</td>\n <td>@twitter</td>\n </tr>\n </tbody>\n </table>\n<pre class=\"prettyprint linenums\">&lt;table class=\"table\"&gt;\n…\n&lt;/table&gt;</pre>\n </div>\n </div>\n</div>\n\n<div class=\"g-grid\">\n <div class=\"g-block\">\n <div class=\"g-content\">\n\t\t <div class=\"g-block box4 nomarginall\">\n\t\t <div class=\"g-content\">\n\t\t \t<h2 class=\"nomarginall g-uppercase\">Forms</h2>\n\t\t </div>\n\t\t\t</div>\n <p>Individual form controls receive styling, but without any required base class on the <code>&lt;form&gt;</code> or large changes in markup. Results in stacked, left-aligned labels on top of form controls.</p>\n <form>\n <fieldset>\n <legend>Legend</legend>\n <label>Label name</label>\n <input type=\"text\" placeholder=\"Type something…\"/><span class=\"help-block\">Example block-level help text here.</span>\n <label class=\"checkbox\">\n <input type=\"checkbox\"/> Check me out\n </label>\n <button type=\"submit\" class=\"btn\">Submit</button>\n </fieldset>\n </form>\n\n<pre class=\"prettyprint linenums\">&lt;form&gt;\n&lt;legend&gt;Legend&lt;/legend&gt;\n&lt;label&gt;Label name&lt;/label&gt;\n&lt;input type=\"text\" placeholder=\"Type something…\"&gt;\n&lt;span class=\"help-block\"&gt;Example block-level help text here.&lt;/span&gt;\n&lt;label class=\"checkbox\"&gt;\n&lt;input type=\"checkbox\"&gt; Check me out\n&lt;/label&gt;\n&lt;button type=\"submit\" class=\"btn\"&gt;Submit&lt;/button&gt;\n&lt;/form&gt;</pre>\n </div>\n </div>\n</div>\n\n<div class=\"g-grid\">\n <div class=\"g-block\">\n <div class=\"g-content\">\n <h4>Inputs</h3>\n <p>Most common form control, text-based input fields. Includes support for all HTML5 types: text, password, datetime, datetime-local, date, month, time, week, number, email, url, search, tel, and color.</p>\n <p>Requires the use of a specified <code>type</code> at all times.</p>\n <form class=\"form-inline\">\n <input type=\"text\" placeholder=\"Text input\"/>\n </form>\n <pre class=\"prettyprint linenums\">&lt;input type=\"text\" placeholder=\"Text input\"&gt;</pre>\n\n <h4>Textarea</h3>\n <p>Form control which supports multiple lines of text. Change <code>row</code> attribute as necessary.</p>\n <form class=\"form-inline\">\n <textarea rows=\"3\"></textarea>\n </form>\n <pre class=\"prettyprint linenums\">&lt;textarea rows=\"3\"&gt;&lt;/textarea&gt;</pre>\n\n <h4>Checkboxes and radios</h3>\n <p>Checkboxes are for selecting one or several options in a list while radios are for selecting one option from many.</p>\n <h4>Default (stacked)</h4>\n <form>\n <label class=\"checkbox\">\n <input type=\"checkbox\" value=\"\"/>\n Option one is this and that—be sure to include why it's great\n </label>\n <br/><label class=\"radio\">\n <input type=\"radio\" name=\"optionsRadios\" id=\"optionsRadios1\" value=\"option1\" checked>\n Option one is this and that—be sure to include why it's great\n </label>\n <label class=\"radio\">\n <input type=\"radio\" name=\"optionsRadios\" id=\"optionsRadios2\" value=\"option2\"/>\n Option two can be something else and selecting it will deselect option one\n </label>\n </form>\n<pre class=\"prettyprint linenums\">&lt;label class=\"checkbox\"&gt;\n&lt;input type=\"checkbox\" value=\"\"&gt;\nOption one is this and that—be sure to include why it's great\n&lt;/label&gt;\n\n&lt;label class=\"radio\"&gt;\n&lt;input type=\"radio\" name=\"optionsRadios\" id=\"optionsRadios1\" value=\"option1\" checked&gt;\nOption one is this and that—be sure to include why it's great\n&lt;/label&gt;\n&lt;label class=\"radio\"&gt;\n&lt;input type=\"radio\" name=\"optionsRadios\" id=\"optionsRadios2\" value=\"option2\"&gt;\nOption two can be something else and selecting it will deselect option one\n&lt;/label&gt;</pre>\n\n <h4>Inline checkboxes</h4>\n <p>Add the <code>.inline</code> class to a series of checkboxes or radios for controls appear on the same line.</p>\n <form>\n <label class=\"checkbox inline\">\n <input type=\"checkbox\" id=\"inlineCheckbox1\" value=\"option1\"/> 1\n </label>\n <label class=\"checkbox inline\">\n <input type=\"checkbox\" id=\"inlineCheckbox2\" value=\"option2\"/> 2\n </label>\n <label class=\"checkbox inline\">\n <input type=\"checkbox\" id=\"inlineCheckbox3\" value=\"option3\"/> 3\n </label>\n </form>\n<pre class=\"prettyprint linenums\">&lt;label class=\"checkbox inline\"&gt;\n&lt;input type=\"checkbox\" id=\"inlineCheckbox1\" value=\"option1\"&gt; 1\n&lt;/label&gt;\n&lt;label class=\"checkbox inline\"&gt;\n&lt;input type=\"checkbox\" id=\"inlineCheckbox2\" value=\"option2\"&gt; 2\n&lt;/label&gt;\n&lt;label class=\"checkbox inline\"&gt;\n&lt;input type=\"checkbox\" id=\"inlineCheckbox3\" value=\"option3\"&gt; 3\n&lt;/label&gt;</pre>\n\n <h4>Selects</h3>\n <p>Use the default option or specify a <code>multiple=\"multiple\"</code> to show multiple options at once.</p>\n <form>\n <select><option>1</option>\n <option>2</option>\n <option>3</option>\n <option>4</option>\n <option>5</option></select><br/><select multiple><option>1</option>\n <option>2</option>\n <option>3</option>\n <option>4</option>\n <option>5</option></select>\n </form>\n<pre class=\"prettyprint linenums\">&lt;select&gt;\n&lt;option&gt;1&lt;/option&gt;\n&lt;option&gt;2&lt;/option&gt;\n&lt;option&gt;3&lt;/option&gt;\n&lt;option&gt;4&lt;/option&gt;\n&lt;option&gt;5&lt;/option&gt;\n&lt;/select&gt;\n\n&lt;select multiple=\"multiple\"&gt;\n&lt;option&gt;1&lt;/option&gt;\n&lt;option&gt;2&lt;/option&gt;\n&lt;option&gt;3&lt;/option&gt;\n&lt;option&gt;4&lt;/option&gt;\n&lt;option&gt;5&lt;/option&gt;\n&lt;/select&gt;</pre>\n </div>\n </div>\n</div>\n\n<div class=\"g-grid\">\n <div class=\"g-block\">\n <div class=\"g-content\">\n\t\t <div class=\"g-block box4 nomarginall\">\n\t\t <div class=\"g-content\">\n\t\t \t<h2 class=\"nomarginall g-uppercase\">Buttons</h2>\n\t\t </div>\n\t\t\t</div>\n\t\t\t<br />\n <form>\n <a class=\"button\" href=\"#\">Link</a>\n <button class=\"button\" type=\"submit\">Button</button>\n <input class=\"button\" type=\"button\" value=\"Input\"/>\n <input class=\"button\" type=\"submit\" value=\"Submit\"/>\n </form>\n<pre class=\"prettyprint linenums\">&lt;a class=\"button\" href=\"\"&gt;Link&lt;/a&gt;\n&lt;button class=\"button\" type=\"submit\"&gt;Button&lt;/button&gt;\n&lt;input class=\"button\" type=\"button\" value=\"Input\"&gt;\n&lt;input class=\"button\" type=\"submit\" value=\"Submit\"&gt;</pre>\n </div>\n </div>\n</div>"

(remember to put the value into some variable, I just gave you the contents)

But it fails on even smaller data.

@mahagr
Copy link
Author
mahagr commented May 22, 2015

I think the best solution would be to internally convert " and ' into something else before using a simpler regexp. Not sure what the side effects of that would be, but it might be the easiest solution to both speed it up and use less stack.

@mahagr
Copy link
Author
mahagr commented May 22, 2015

As crashing your Apache may be bad idea (and issue only affects Windows), you may try to add this to your php.ini to get it to fail:

pcre.recursion_limit=1000

@mahagr
Copy link
Author
mahagr commented May 22, 2015

After some testing, it looks like possessive quantifiers fixes the issue:

const REGEX_QUOTED_STRING = '(?:"([^"\\\\]++|\\\\.)*"|\'([^\'\\\\]++|\\\\.)*\')';

@mahagr
Copy link
Author
mahagr commented May 22, 2015

I'm taking that back, there seem to be some issues with that one... Second expression is wrong..

@mahagr
Copy link
Author
mahagr commented May 22, 2015

Reverted the second part back to what it was and this seems to work so far:

const REGEX_QUOTED_STRING = '(?:"([^"\\\\]++|\\\\.)*"|\'([^\']*(?:\'\'[^\']*)*)\')';

Not sure if single quoted one has the same issues or if its fine.

@mahagr
Copy link
Author
mahagr commented May 22, 2015

Looks like that even that doesn't really fix the issue. Bah..

@mahagr
Copy link
Author
mahagr commented Oct 6, 2015

Any ideas on how to fix this one? One way would be to replace first all instances of /" and then do simpler regexp.

@GuilhemN
Copy link
Contributor

Maybe using a StringReader would fix your issue?
It is based on masks (strspn, strcspn) instead of regexs.

@mahagr
Copy link
Author
mahagr commented Aug 30, 2016

Interesting... Even if StringReader is slower than regexps in general, it would be much faster in case of parsing html inside the yaml string as it wouldn't use megabytes of memory trying to parse escaped "

@xabbuh
Copy link
Member
xabbuh commented Jan 14, 2017

This should be fixed by #20411 now.

@xabbuh xabbuh closed this as completed Jan 14, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants
0