Git Product home page Git Product logo

Comments (6)

dmitshur avatar dmitshur commented on June 9, 2024

#81 is related.

It fixed relative links, but it considers only those links that start with / to be relative.

See func isRelativeLink(link []byte) (yes bool) for the current logic of what constitutes a relative link.

So, if you apply this patch to your example:

diff --git a/gistfile1.go b/gistfile1.go
index 19f4e6e..07adaf6 100644
--- a/gistfile1.go
+++ b/gistfile1.go
@@ -7,8 +7,8 @@ import (

 func main() {
    outb := blackfriday.MarkdownCommon([]byte(`
-![pic](media/pic.png)
-[url](docs/doc.html)
+![pic](/media/pic.png)
+[url](/docs/doc.html)
 `))
    fmt.Print(string(outb))
 }
\ No newline at end of file

Then the output is:

<p><img src="/media/pic.png" alt="pic"/>

<a href="/docs/doc.html">url</a></p>

Can you confirm/deny if that solves your problem?

from blackfriday.

ancientlore avatar ancientlore commented on June 9, 2024

It does allow the Markdown to render the URL - however in my case that is the wrong URL. Starting with slash is an absolute reference to the server root, not a relative reference. My pages are rooted in another location, so I need a true relative reference. It seems like isRelativeLink is actually testing for an absolute link on the same server.

from blackfriday.

mprobst avatar mprobst commented on June 9, 2024

Note that relative URLs are notoriously hard to sanitise - make sure that
this doesn't compromise sanitisation.

On Donnerstag, 29. Mai 2014 16:22:21, Michael Lore [email protected]
wrote:

It does allow the Markdown to render the URL - however in my case that is
the wrong URL. Starting with slash is an absolute reference to the
server root, not a relative reference. My pages are rooted in another
location, so I need a true relative reference.


Reply to this email directly or view it on GitHubhttps://github.com//issues/87#issuecomment-44536838
.

from blackfriday.

ancientlore avatar ancientlore commented on June 9, 2024

In my case I may be able to disable sanitization. I will try it.

from blackfriday.

ancientlore avatar ancientlore commented on June 9, 2024

Yeah that will work for me because my application doesn't allow random users to input Markdown. So I have a solution - just need to decide how you want sanitization to work for that scenario.

from blackfriday.

rtfb avatar rtfb commented on June 9, 2024

Now when Blackfriday no longer attempts to do sanitization internally, it renders them fine again. Closing.

from blackfriday.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.