<commit_before>$(document).ready(function() {
	if(typeof FileActions!=='undefined'){
		FileActions.register('image','View','',function(filename){
			viewImage($('#dir').val(),filename);
		});
		FileActions.setDefault('image','View');
	}
	OC.search.customResults.Images=function(row,item){
		var image=item.link.substr(item.link.indexOf('?file=')+6);
		var a=row.find('a');
		a.attr('href','#');
		a.click(function(){
			var pos=image.lastIndexOf('/')
			var file=image.substr(pos + 1);
			var dir=image.substr(0,pos);
			viewImage(dir,file);
		});
	}
});

function viewImage(dir, file) {
	if(file.indexOf('.psd')>0){//can't view those
		return;
	}
	var location=OC.filePath('files','ajax','download.php')+'?files='+file+'&dir='+dir;
	$.fancybox({
		"href": location,
		"title": file,
		"titlePosition": "inside"
	});
}<commit_msg>prevent xss attacks by manipulating image file names<commit_after>$(document).ready(function() {
	if(typeof FileActions!=='undefined'){
		FileActions.register('image','View','',function(filename){
			viewImage($('#dir').val(),filename);
		});
		FileActions.setDefault('image','View');
	}
	OC.search.customResults.Images=function(row,item){
		var image=item.link.substr(item.link.indexOf('?file=')+6);
		var a=row.find('a');
		a.attr('href','#');
		a.click(function(){
			var pos=image.lastIndexOf('/')
			var file=image.substr(pos + 1);
			var dir=image.substr(0,pos);
			viewImage(dir,file);
		});
	}
});

function viewImage(dir, file) {
	if(file.indexOf('.psd')>0){//can't view those
		return;
	}
	var location=OC.filePath('files','ajax','download.php')+'?files='+file+'&dir='+dir;
	$.fancybox({
		"href": location,
		"title": file.replace(/</, "&lt;").replace(/>/, "&gt;"),
		"titlePosition": "inside"
	});
}
{'fraction_non_alphanumeric': 0.24238943136128663, 'fraction_numerical': 0.004595060310166571, 'mean_word_length': 5.751937984496124, 'pattern_counts': {'":': 6, '<': 4, '<?xml version=': 0, '>': 6, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1542508', 'n_tokens_mistral': 684, 'n_tokens_neox': 631, 'n_words': 83}