Skip to content
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

fix gfm extended autolinking requiring multiple backpedals #1293

Merged
merged 3 commits into from
Jul 5, 2018
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
8 changes: 6 additions & 2 deletions lib/marked.js
Original file line number Diff line number Diff line change
Expand Up @@ -655,7 +655,8 @@ InlineLexer.prototype.output = function(src) {
text,
href,
title,
cap;
cap,
prevCapZero;

while (src) {
// escape
Expand All @@ -681,7 +682,10 @@ InlineLexer.prototype.output = function(src) {

// url (gfm)
if (!this.inLink && (cap = this.rules.url.exec(src))) {
cap[0] = this.rules._backpedal.exec(cap[0])[0];
do {
prevCapZero = cap[0];
cap[0] = this.rules._backpedal.exec(cap[0])[0];
} while (prevCapZero !== cap[0]);
src = src.substring(cap[0].length);
if (cap[2] === '@') {
text = escape(cap[0]);
Expand Down
15 changes: 15 additions & 0 deletions test/specs/marked/marked-spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,21 @@ Messenger.prototype.test = function(spec, section, ignore) {

var messenger = new Messenger();

describe('Marked Autolinks', function() {
var section = 'Autolinks';

// var shouldPassButFails = [];
Copy link
Contributor

@davisjam davisjam Jun 27, 2018

Choose a reason for hiding this comment

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

Not sure why this line is here? Seems to duplicate the next line.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It's a copy/paste from elsewhere in the same file. See lines 53 and 68. I'll remove them all.

var shouldPassButFails = [];

var willNotBeAttemptedByCoreTeam = [];

var ignore = shouldPassButFails.concat(willNotBeAttemptedByCoreTeam);

markedSpec.forEach(function(spec) {
messenger.test(spec, section, ignore);
});
});

describe('Marked Code spans', function() {
var section = 'Code spans';

Expand Down
6 changes: 6 additions & 0 deletions test/specs/marked/marked.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
[
{
"section": "Autolinks",
"markdown": "(See https://www.example.com/fhqwhgads.)",
"html": "<p>(See <a href=\"https://www.example.com/fhqwhgads\">https://www.example.com/fhqwhgads</a>.)</p>",
"example": 10
},
{
"section": "Code spans",
"markdown": "`someone@example.com`",
Expand Down