-
Notifications
You must be signed in to change notification settings - Fork 238
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
How to sanitize input text #197
Comments
Could you give us a concrete example of what you are talking about? It would help to understand what is problematic. :) |
Sure. If user input is: I need to render: So html characters This is something that Linkify plugin has solved but I don't see how I should do it using Autolinker.js. |
Not quite sure if I understand your question, but the goal of Autolinker is to link as much as possible so yeah, I think Autolinker will link the first link and also keep the the second part as a link. If you see a structure that Autolinker could have that could allow this, feel free to tell us and we'll see if we can implement it ! :) |
We both probably agree that Autolinker output is meant to be inserted into HTML. And that the original input we want to transform comes from the website user. For example we we want to improve his comment by making URLs clickable. Right? Somewhere between the user inputting his text and rendering the output into HTML two things has to happen:
My question is how these these things should be orchestrated together. Linkify does both. Autolinker seems to perform only the second one and I don't know where to sanitize input without distorting URLs (concretely the |
Side note: I already decided for Linkify over Autolinker because of this. But I would like to understand how do you expect this to be handled. Probably I'm just missing something. 😄 |
After further investigation it seems that Autolinker behavior is very similar to linkifyHtml method, which preserves HTML tags compared to linkifyStr method which escapes them. Input: linkifyStr: linkifyHtml: Autolinker: |
Upvote to add an option to disable html parsing and threat input as text as the linlkyStr example above. |
I'm using this in conjunction with sanitize-html. First I run the text through the autolinker plugin, and then that output thru sanitize-html |
Did this issue get closed via #313 ? |
Is there a recommended way hot to sanitize text before passing it to Autolinker? The usual way to escape html tags will also distort some URLs.
The text was updated successfully, but these errors were encountered: