By using this plugin we can convert normal text to HTML feed like Facebook and with links and Encoded format to avoid XSS attack. This plugin was inspired by jquery-linkify plugin and XSS prevention cheat sheet
Features :
- Converting URL's to Links
- Add user link to the words specified as '@...'
- Add search links to the words specified as '#...'
- Encode data to display as HTML to avoid XSS attack
How it works ? :
- Converts http://www.google.com -- to -- http://www.google.com
- Converts @SodhanaLibrary --to-- @SodhanaLibrary
- Converts #jQuery --to-- #jQuery
- Converts admin@sodhanalibrary.com --to-- admin@sodhanalibrary.com
- Encrypts & to &
- Encrypts < to <
- Encrypts > to >
- Encrypts " to "
- Encrypts ' to '
Installation :
<script type='text/javascript' src='http://code.jquery.com/jquery-1.8.3.js'></script> <script type='text/javascript' src='/js/jQuery.feedify.js'></script>
Usage :
var text = 'Hi my twitter account is @SodhanaLibrary #Contact me at admin@sodhanalibrary.com <script>alert("hi")</script>'; var feedified= $.feedify(text);
The output will be
Hi my twitter account is @SodhanaLibrary #Contact me at admin@sodhanalibrary.com <script>alert("hi")</script>
Disable Features :
If you don't want to search hash links then you can disable it
var text = "i like #jQuery"; var options = { hash: false } var feedified = $.feedify(text, options);
Add your own regular expressions to replace Text pattern :
var text = "My name is srinivas and i was born on 1990/08/25"; var options = { dates: { regex: /(^|\s)(\d{4})([- /.])(\d{2})([- /.])(\d{2})/i, template: '$1<span class="date">$6-$4-$2</span>' } } var feedified = $.feedify(text, options);
The output will be :
My name is srinivas and i was born on 26-08-1990
Thank you for the good writeup. It in fact was a amusement account it.
ReplyDeleteLook advanced to far added agreeable from you! By the way, how could we communicate?
Jeff Van Beaver
Great blog here! Additionally your web site a lot up very fast!
ReplyDeleteWhat web host are you the usage of? Can I am getting your *****ociate link to your host?
I wish my site loaded up as quickly as yours lol Acts 1:8 Foundation