Skip to content

Commit

Permalink
Merge pull request #852 from support-project/issue845_escape_link
Browse files Browse the repository at this point in the history
#845 escape link url for bookmark type
  • Loading branch information
koda-masaru authored Sep 13, 2017
2 parents cf290ed + c93f3cd commit f3f1a54
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
11 changes: 11 additions & 0 deletions src/main/webapp/js/common.js
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,17 @@ function unescapeHTML(str) {
return div.textContent || div.innerText;
};

function escapeLink(url) {
if (url.toLowerCase().indexOf('javascript:') != -1) {
var conv = '';
conv += url.substring(0, url.toLowerCase().indexOf('javascript:'));
conv += encodeURIComponent(url.substring(url.toLowerCase().indexOf('javascript:')));
return conv;
} else {
return url;
}
}

var handleErrorResponse = function(xhr, textStatus, error) {
console.log(error);
console.log(xhr);
Expand Down
2 changes: 1 addition & 1 deletion src/main/webapp/js/template-item-view.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ $(document).ready(function() {
url = item.itemValue;
}
tag += '<h4>' + item.itemName + ': ';
tag += '<a href="' + url + '" target="_blank" >' + url + '</a></h4>';
tag += '<a href="' + escapeLink(url) + '" target="_blank" >' + url + '</a></h4>';
return tag;
};
var createRadioItem = function(item) {
Expand Down

0 comments on commit f3f1a54

Please sign in to comment.