Escape in JavaScript

This commit is contained in:
Naoki Takezoe
2018-01-13 16:48:21 +09:00
parent 275772ad00
commit 2180e31d13
3 changed files with 8 additions and 12 deletions

View File

@@ -537,10 +537,6 @@ object RepositoryService {
(id, path.substring(id.length).stripPrefix("/"))
}
// def getReleaseByTag(tag: String)(implicit s: Session): Option[Release] = {
// Releases filter (_.byTag(owner, name, tag)) firstOption
// }
}
def httpUrl(owner: String, name: String)(implicit context: Context): String = s"${context.baseUrl}/git/${owner}/${name}.git"

View File

@@ -75,9 +75,9 @@ $(function(){
success: function(file, id) {
var attach =
'<li><a href="@context.baseUrl/@repository.owner/@repository.name/_release/@helpers.encodeRefName(tag)/' + id + '">' +
'<i class="octicon octicon-file"></i>' + file.name + '</a>' +
'<i class="octicon octicon-file"></i>' + escapeHtml(file.name) + '</a>' +
'<a href="#" class="remove pull-right" style="padding-top: 0px;">(remove)</a>' +
'<input type="hidden" name="file:' + id + '" value="' + file.name + '"/>' + // TODO escape file.name
'<input type="hidden" name="file:' + id + '" value="' + escapeHtml(file.name) + '"/>'
'</li>';
$('#assets-list').append(attach);
$(file.previewElement).prevAll('div.dz-preview').addBack().remove();

View File

@@ -351,12 +351,12 @@ function scrollIntoView(target){
}
}
///**
// * escape html
// */
//function escapeHtml(text){
// return text.replace(/&/g,'&amp;').replace(/</g,'&lt;').replace(/"/g,'&quot;').replace(/>/g,'&gt;');
//}
/**
* escape html
*/
function escapeHtml(text){
return text.replace(/&/g,'&amp;').replace(/</g,'&lt;').replace(/"/g,'&quot;').replace(/>/g,'&gt;');
}
/**
* calculate string ranking for path.