Git Product home page Git Product logo

jquery-linkify's Introduction

Linkify jQuery Plugin

Linkify is jQuery plugin to formatting the text that contains URL or hashtag into a clickable HTML content.

It's small, it has no test suite but handles the large majority of cases, with exceptions (e.g. detecting modern TLDs like .museum properly, or punctuation at the end of the URL). For advanced options, check out the linkify or the urlize library.

Usage

Include the plugin script

<script src="jquery.linkify.js" type="text/javascript"></script>
$("#content").linkify();

or to enable the hashtag link

function toHashtagUrl(hashtag) {
  return "http://myservice.com?q=" + hashtag;
}

$("#content-with-hashtag").linkify(toHashtagUrl);

or if you want to disable the URL that does't include http

function toHashtagUrl(hashtag) {
  return "http://myservice.com?q=" + hashtag;
}

$("#content-with-hashtag").linkify({
	hashtagUrlBuilder: toHashtagUrl, 
	includeW3: false
});

or to specify the target for links

$("#content").linkify({
	target: "_blank"
});

jquery-linkify's People

Contributors

bradbeattie avatar dandv avatar davecowart avatar laszlof avatar rbpinheiro avatar tchalvak avatar uudashr avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

jquery-linkify's Issues

Add rel="nofollow" by default.

Ok, so when linkifying anything, it's just going to be a js-only effect. As such, rel="nofollow" doesn't seem that critical (only search engines that parse js would actually see the effects on linkify). But if you use linkify on user-generated content (the use case that is most applicable to not just doing it server-side) random spammers who come by a site are going to see $$$ chi-ching, links that they can create that don't appear to be nofollowed, that appear to pass link juice.

So I think to avoid the appearance of vulnerability to spamming, the links created should get rel='nofollow' by default. Of course, the added bonus of a setting to take off nofollow would be nice, though I'm not sure that's even necessary since the use case for non-nofollow js-created dynamic links is a tiny subset of use-cases.

XSS Vulnerability

The change introduced to make linkify only run on text nodes has actually introduced a major XSS problem. Because the value of the node is retrieved as text, but put back as HTML, it will actually convert any HTML-encoded tags into HTML.

See http://jsfiddle.net/BH9Kc/ for a proof of concept (contains current version of linkify inline). The page previously contained a completely safe HTML-encoded script tag, but once linkify is run it gets executed.

This bug was introduced with commit 07286dd. Reverting this commit stops the problem, but probably reintroduces the problems with running on non-text nodes.

What license governs jquery-linkify?

Hi @uudashr . I've noticed that you have licensed several other projects under the MIT License but cannot find any licensing information for jquery-linkify. What license applies to this project? Thanks very much.

Leading whitespaces are trimmed

Code:

         some text
.

When using linkify leading spaces (before "some text" in example above) are removed. It should not happen.

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.