Skip to content

Commit

Permalink
Expanded url protocol check to allow https, mailto and protocol-less …
Browse files Browse the repository at this point in the history
…URLs. Fixes: #180
  • Loading branch information
acrobat committed Dec 14, 2015
1 parent c2fb640 commit 5953ec5
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions js/bootstrap-markdown.js
Original file line number Diff line number Diff line change
Expand Up @@ -1037,7 +1037,8 @@

link = prompt(e.__localize('Insert Hyperlink'),'http://');

if (link !== null && link !== '' && link !== 'http://' && link.substr(0,4) === 'http') {
var urlRegex = new RegExp('^((http|https)://|(mailto:)|(//))[a-z0-9]', 'i');
if (link !== null && link !== '' && link !== 'http://' && urlRegex.test(link)) {
var sanitizedLink = $('<div>'+link+'</div>').text();

// transform selection and set the cursor into chunked text
Expand Down Expand Up @@ -1066,7 +1067,8 @@

link = prompt(e.__localize('Insert Image Hyperlink'),'http://');

if (link !== null && link !== '' && link !== 'http://' && link.substr(0,4) === 'http') {
var urlRegex = new RegExp('^((http|https)://|(//))[a-z0-9]', 'i');
if (link !== null && link !== '' && link !== 'http://' && urlRegex.test(link)) {
var sanitizedLink = $('<div>'+link+'</div>').text();

// transform selection and set the cursor into chunked text
Expand Down

0 comments on commit 5953ec5

Please sign in to comment.