Browse Source

Fix code coverage in references

pull/41/head
Alex Kocharin 10 years ago
parent
commit
8ca0b5b52b
  1. 3
      lib/rules_block/reference.js
  2. 12
      test/fixtures/markdown-it/commonmark_extras.txt
  3. 8
      test/fixtures/markdown-it/xss.txt

3
lib/rules_block/reference.js

@ -27,14 +27,13 @@ module.exports = function reference(state, startLine, _endLine, silent) {
max = state.eMarks[startLine], max = state.eMarks[startLine],
nextLine = startLine + 1; nextLine = startLine + 1;
if (pos >= max) { return false; }
if (state.src.charCodeAt(pos) !== 0x5B/* [ */) { return false; } if (state.src.charCodeAt(pos) !== 0x5B/* [ */) { return false; }
endLine = state.lineMax; endLine = state.lineMax;
// jump line-by-line until empty one or EOF // jump line-by-line until empty one or EOF
if (nextLine < endLine && !state.isEmpty(nextLine)) { if (nextLine < endLine && !state.isEmpty(nextLine)) {
terminatorRules = state.md.block.ruler.getRules('references'); terminatorRules = state.md.block.ruler.getRules('reference');
for (; nextLine < endLine && !state.isEmpty(nextLine); nextLine++) { for (; nextLine < endLine && !state.isEmpty(nextLine); nextLine++) {
// this would be a code block normally, but after paragraph // this would be a code block normally, but after paragraph

12
test/fixtures/markdown-it/commonmark_extras.txt

@ -231,3 +231,15 @@ Coverage. Link
. .
<p>[test](</p> <p>[test](</p>
. .
Coverage. Reference
.
[
test\
]: 123
foo
bar
.
<p>foo
bar</p>
.

8
test/fixtures/markdown-it/xss.txt

@ -77,3 +77,11 @@ javascript:alert(1)
<p>javascript:alert(1)</p> <p>javascript:alert(1)</p>
<p>javascript:alert(1)</p> <p>javascript:alert(1)</p>
. .
References
.
[test]: javascript:alert(1)
.
<p>[test]: javascript:alert(1)</p>
.

Loading…
Cancel
Save