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("/")) (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" 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) { success: function(file, id) {
var attach = var attach =
'<li><a href="@context.baseUrl/@repository.owner/@repository.name/_release/@helpers.encodeRefName(tag)/' + id + '">' + '<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>' + '<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>'; '</li>';
$('#assets-list').append(attach); $('#assets-list').append(attach);
$(file.previewElement).prevAll('div.dz-preview').addBack().remove(); $(file.previewElement).prevAll('div.dz-preview').addBack().remove();

View File

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