Project

General

Profile

Feature #44642 » 0002-Include-seconds-in-pasted-image-filenames.patch

Go MAEDA, 2026-10-29 00:54

View differences:

app/assets/javascripts/attachments.js
const inlineFilename = encodeURIComponent(sanitizedFilename)
.replace(/[!()]/g, function(match) { return "%" + match.charCodeAt(0).toString(16) });
const isFromClipboard = /^clipboard-\d{12}-[a-z0-9]{5}\.\w+$/.test(file.name);
const isFromClipboard = /^clipboard-\d{14}-[a-z0-9]{5}\.\w+$/.test(file.name);
let imageDisplayWidth;
if (isFromClipboard) {
const imageWidth = await getImageWidth(file).catch(() => 0);
......
+ ('0'+date.getDate()).slice(-2)
+ ('0'+date.getHours()).slice(-2)
+ ('0'+date.getMinutes()).slice(-2)
+ ('0'+date.getSeconds()).slice(-2)
+ '-' + randomKey(5).toLocaleLowerCase()
+ '.' + file.name.split('.').pop();
test/system/issues_test.rb
document.getElementById('issue_description').dispatchEvent(event);
JS
filename = find('.attachments_fields input.filename').value
assert_match /\Aclipboard-\d{12}-[a-z0-9]{5}\.png\z/, filename
assert_match /\Aclipboard-\d{14}-[a-z0-9]{5}\.png\z/, filename
assert_field 'issue_description', :with => %(<img style="width: 1px;" src="#{filename}"><br>\n)
end
(3-3/3)