Feature #44642 » 0001-Include-seconds-in-pasted-image-filenames.patch
| 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 | ||
|---|---|---|
|
assert_selector '.attachments_fields > span', :count => 2
|
||
|
end
|
||
|
def test_pasted_image_filename_should_include_seconds
|
||
|
set_tmp_attachments_directory
|
||
|
log_user('jsmith', 'jsmith')
|
||
|
visit '/projects/ecookbook/issues/new'
|
||
|
page.execute_script(<<~JS)
|
||
|
const RealDate = Date;
|
||
|
window.Date = class extends RealDate {
|
||
|
constructor(...args) {
|
||
|
super(...(args.length ? args : [2026, 9, 19, 18, 3, 59]));
|
||
|
}
|
||
|
};
|
||
|
// 1x1 1-bit grayscale PNG image
|
||
|
const png = Uint8Array.from(atob('iVBORw0KGgoAAAANSUhEUgAAAAEAAAABAQAAAAA3bvkkAAAACklEQVR42mNgAAAAAgAB5Sfe/AAAAABJRU5ErkJggg=='), c => c.charCodeAt(0));
|
||
|
const clipboardData = new DataTransfer();
|
||
|
clipboardData.items.add(new File([png], 'image.png', { type: 'image/png' }));
|
||
|
const event = new Event('paste', { bubbles: true, cancelable: true });
|
||
|
Object.defineProperty(event, 'clipboardData', { value: clipboardData });
|
||
|
document.getElementById('issue_description').dispatchEvent(event);
|
||
|
window.Date = RealDate;
|
||
|
JS
|
||
|
filename = find('.attachments_fields input.filename').value
|
||
|
assert_match /\Aclipboard-20261019180359-[a-z0-9]{5}\.png\z/, filename
|
||
|
end
|
||
|
def test_create_issue_with_new_target_version
|
||
|
log_user('jsmith', 'jsmith')
|
||