This file is indexed.

/usr/share/tdiary/js/image.js is in tdiary-plugin 3.2.2-3.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
/*
 image.js: javascript for image.rb plugin of tDiary

 Copyright (C) 2011 by TADA Tadashi <t@tdtds.jp>
 Copyright (C) 2011 by hb <smallstyle@gmail.com>
 You can redistribute it and/or modify it under GPL2.
 */

function insertImage(text){
	$('#body').insertAtCaret(text);
}

$(function(){
	$('.image-img')
	.live('hover', function(){
		$(this).css('cursor', 'pointer');
	}, function(){
		$(this).css('cursor', 'default');
	})
	.live('click', function(){
		var idx = this.id.replace('image-index-', '');
		var w = $('#image-info-' + idx + ' .image-width').text();
		var h = $('#image-info-' + idx + ' .image-height').text();
		$('#body').insertAtCaret($.makePluginTag('image', function(){
			return [idx, "'" + $tDiary.plugin.image.alt + "'", 'nil', '[' + w + ',' + h + ']']
		}));
	});
	
	var ImagePlugin = function(url){
		this.url =url;
	};
	ImagePlugin.prototype = {
		upload: function(formData, callback){
			$.ajax({
				url: this.url,
				type: 'post',
				data: formData,
				processData: false,
				contentType: false,
				beforeSend: function(){
					$('#plugin-image-addimage input[type="submit"]').attr('disabled', 'disabled');
					$('#plugin-image-uploading').show();
				},
				success: function(data){
					callback(data);
				},
				complete: function(){
					$('#plugin-image-addimage input[type="submit"]').removeAttr('disabled');
					$('#plugin-image-uploading').hide();
				}
			});
		},
		
		remove: function(data, callback){
			$.ajax({
				url: this.url,
				type: 'post',
				data: data,
				dataType: 'html',
				success: function(response){
					callback();
				}				
			});
		}
	};
	
	$('#plugin-image-addimage input[name="plugin"]')
	.after($('<span>', {text: 'Uploading...'}).attr('id', 'plugin-image-uploading').hide());
		
	$('#plugin-image-addimage form')
	.submit(function(e){
		if(typeof(FormData) == 'undefined') {
			return true;
		}
		e.preventDefault();
		
		uploadFiles(this.plugin_image_file.files);
		this.reset();
		return false;
	});
	
	var uploadFiles = function(files) {
		var formData = new FormData();
		formData.append('plugin', 'image');
		$.each($('#plugin-image-addimage input[type="hidden"]'), function(){
			formData.append($(this).attr('name'), $(this).val());
		});
		$.each(files, function(i, file){
			formData.append('plugin_image_file', file);
		});

		var imagePlugin = new ImagePlugin($(this).attr('action'));
		imagePlugin.upload(formData, function(result){
			$('#plugin-image-delimage').parents('div.form').remove();
			$('<div>')
				.attr({
					'class': 'form'
				})
				.append($('#plugin-image-delimage', result).parents('div.form').html())
				.insertBefore('#plugin-image-addimage');
			var timestamp = new Date().getTime();
			$.each($('#plugin-image-delimage img'), function(){
				$(this).attr('src', $(this).attr('src') + '?' + timestamp);
			});
		});
		return false;
	};

	$('#plugin-image-delimage')
	.live('submit', function(e){
		e.preventDefault();
		
		var ids = $.map($('#image-table input[name="plugin_image_id"]:checked'), function(i){
			return $(i).val();
		});
		var imagePlugin = new ImagePlugin($(this).attr('action'));
		imagePlugin.remove($(this).serialize() + '&plugin=image', function(){
			$.each(ids, function(i, id){
				$('#image-index-' + id).parent().fadeOut();
				$('#image-info-' + id).fadeOut();
			});
		});
		return false;
	});

	if(window.File) {
		$('<div>')
			.attr({
				id: 'plugin_image_dnd'
			})
			.css({
				'height': '5em',
				'text-align': 'center',
				'line-height': '5em',
				'background': '#ddd',
				'border': 'dashed 3px #AAA'
			})
			.bind('dragenter', function(){
				$(this).css('border', 'solid 3px #AAA');
				return false;
			})
			.bind('dragleave', function(){
				$(this).css('border', 'dashed 3px #CCC');
				return false;
			})
			.bind('drop', function(e){
				$('#plugin_image_dnd').hide();
				$(this).css('border', 'dashed 3px #CCC');
				$('#plugin-image-addimage form').show();
				var files = e.originalEvent.dataTransfer.files;
				uploadFiles(files);
				return false;
			})
			.text($tDiary.plugin.image.drop_here)
			.hide()
			.appendTo('#plugin-image-addimage');

		var dnd_timer = false;
		$('body')
			.bind('dragenter', function() {
				if (dnd_timer) {
					clearTimeout( dnd_timer );
				}
				$('#plugin-image-addimage form').hide();
				$('#plugin_image_dnd').show();
			})
			.bind('dragover', function(){
				if (dnd_timer) {
					clearTimeout( dnd_timer );
				}
				return false;
			})
			.bind('dragleave', function(){
				dnd_timer = setTimeout(function(){
					$('#plugin_image_dnd').hide();
					$('#plugin-image-addimage form').show();
				}, 500);
				return false;
			});
	}
});