Fixes silent disappearance of Markdown (pseudo-)link when it's detected as unsafe protocol. Now it will be converted to plain text in spirit of [the specification](https://spec.commonmark.org/0.30/#links). For that sake the check for protocol is added to rst.nim also.
This commit is contained in:
parent
4b0636fba0
commit
801c0f0369
4 changed files with 81 additions and 40 deletions
|
|
@ -1593,8 +1593,15 @@ suite "invalid targets":
|
|||
test "invalid links":
|
||||
check("(([Nim](https://nim-lang.org/)))".toHtml ==
|
||||
"""((<a class="reference external" href="https://nim-lang.org/">Nim</a>))""")
|
||||
check("(([Nim](javascript://nim-lang.org/)))".toHtml ==
|
||||
"""((<a class="reference external" href="">Nim</a>))""")
|
||||
# unknown protocol is treated just like plain text, not a link
|
||||
var warnings = new seq[string]
|
||||
check("(([Nim](javascript://nim-lang.org/)))".toHtml(warnings=warnings) ==
|
||||
"""(([Nim](javascript://nim-lang.org/)))""")
|
||||
check(warnings[] == @["input(1, 9) Warning: broken link 'javascript'"])
|
||||
warnings[].setLen 0
|
||||
check("`Nim <javascript://nim-lang.org/>`_".toHtml(warnings=warnings) ==
|
||||
"""Nim <javascript://nim-lang.org/>""")
|
||||
check(warnings[] == @["input(1, 33) Warning: broken link 'javascript'"])
|
||||
|
||||
suite "local file inclusion":
|
||||
test "cannot include files in sandboxed mode":
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue