Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions lib/marked.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ block.normal = merge({}, block);
*/

block.gfm = merge({}, block.normal, {
fences: /^ *(`{3,}|~{3,})[ \.]*(\S+)? *\n([\s\S]*?)\n? *\1 *(?:\n+|$)/,
fences: /^ {0,3}(`{3,}|~{3,})([^`\n]*)\n(?:|([\s\S]*?)\n)(?: {0,3}\1[~`]* *(?:\n+|$)|$)/,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is no more vulnerable than it previously was.

paragraph: /^/,
heading: /^ *(#{1,6}) +([^\n]+?) *#* *(?:\n+|$)/
});
Expand Down Expand Up @@ -231,7 +231,7 @@ Lexer.prototype.token = function(src, top) {
src = src.substring(cap[0].length);
this.tokens.push({
type: 'code',
lang: cap[2],
lang: cap[2] ? cap[2].trim() : cap[2],
text: cap[3] || ''
});
continue;
Expand Down Expand Up @@ -920,7 +920,8 @@ function Renderer(options) {
this.options = options || marked.defaults;
}

Renderer.prototype.code = function(code, lang, escaped) {
Renderer.prototype.code = function(code, infostring, escaped) {
var lang = (infostring || '').match(/\S*/)[0];
if (this.options.highlight) {
var out = this.options.highlight(code, lang);
if (out != null && out !== code) {
Expand Down
5 changes: 5 additions & 0 deletions test/new/gfm_code.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,8 @@


</code></pre>

<p>Closing fences must lay on a new line:</p>
<pre><code>hello()
^```
&quot;this should still be in the code block!&quot;</code></pre>
8 changes: 8 additions & 0 deletions test/new/gfm_code.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,11 @@ ciao


```

Closing fences must lay on a new line:

```
hello()
^```
"this should still be in the code block!"
```
3 changes: 1 addition & 2 deletions test/specs/commonmark/commonmark-spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -159,8 +159,7 @@ describe('CommonMark 0.28 Indented code blocks', function() {
describe('CommonMark 0.28 Fenced code blocks', function() {
var section = 'Fenced code blocks';

// var shouldPassButFails = [];
var shouldPassButFails = [93, 95, 96, 97, 106, 108, 112];
var shouldPassButFails = [];

var willNotBeAttemptedByCoreTeam = [];

Expand Down