Tygs / 0bin

Client side encrypted pastebin
https://0bin.net
Do What The F*ck You Want To Public License
1.38k stars 197 forks source link

FR #49 : make URL clickable automatically #76

Closed BoboTiG closed 5 years ago

BoboTiG commented 9 years ago

A first try to make URL clickable automatically. What do you think? The second commit will prevent XSS, in theory.

For better security, we could add a function callback to content.replace to check if there is at least one replacement. If so, then we use $('#paste-content').html() else $('#paste-content').text().

sametmax commented 9 years ago

Have you checked if it work with HTML code paste such as http://0bin.net/paste/QOFtPlUYSmdpTLmL#F1Q14RcqqzlshPx6xMm+mSNLq80bdRSHWFwsWysrdt6 ? I haven't tried your code yet, but I feel like converting the URL inside would break it.

BoboTiG commented 9 years ago

It does not work with your example. I am working on that.

BoboTiG commented 9 years ago

This should be good. The solution works as:

  1. Parse URL to a special pattern (||a|| instead of <a and ||/||a> for </a>)
  2. Escape tag opener character (< to &lt;)
  3. Replace pattern by tag opener character (||a|| to <a and ||/||a> to </a>)

It is not beautiful but it works.

rugk commented 8 years ago

Any news on this PR?

auzias commented 8 years ago

Does the URL parser avoid URL such as file://, if you know what I mean ?