Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
drupal
Manage
Activity
Members
Labels
Plan
Wiki
Custom issue tracker
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Model registry
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
project
drupal
Commits
63efacbb
Verified
Commit
63efacbb
authored
Dec 18, 2019
by
Lee Rowlands
Browse files
Options
Downloads
Patches
Plain Diff
SA-
CORE-2019
-010 by larowlan, greggles, mlhess, kim.pepper, alexpott, dww, xjm, David_Rothstein
parent
7ae15f9c
No related branches found
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
core/modules/file/file.module
+1
-1
1 addition, 1 deletion
core/modules/file/file.module
core/modules/file/tests/src/Functional/FileManagedFileElementTest.php
+17
-0
17 additions, 0 deletions
.../file/tests/src/Functional/FileManagedFileElementTest.php
with
18 additions
and
1 deletion
core/modules/file/file.module
+
1
−
1
View file @
63efacbb
...
@@ -992,7 +992,7 @@ function _file_save_upload_single(\SplFileInfo $file_info, $form_field_name, $va
...
@@ -992,7 +992,7 @@ function _file_save_upload_single(\SplFileInfo $file_info, $form_field_name, $va
$values
=
[
$values
=
[
'uid'
=>
$user
->
id
(),
'uid'
=>
$user
->
id
(),
'status'
=>
0
,
'status'
=>
0
,
'filename'
=>
$file_info
->
getClientOriginalName
(),
'filename'
=>
trim
(
$file_info
->
getClientOriginalName
(),
'.'
),
'uri'
=>
$file_info
->
getRealPath
(),
'uri'
=>
$file_info
->
getRealPath
(),
'filesize'
=>
$file_info
->
getSize
(),
'filesize'
=>
$file_info
->
getSize
(),
];
];
...
...
This diff is collapsed.
Click to expand it.
core/modules/file/tests/src/Functional/FileManagedFileElementTest.php
+
17
−
0
View file @
63efacbb
...
@@ -2,6 +2,8 @@
...
@@ -2,6 +2,8 @@
namespace
Drupal\Tests\file\Functional
;
namespace
Drupal\Tests\file\Functional
;
use
Drupal\file\Entity\File
;
/**
/**
* Tests the 'managed_file' element type.
* Tests the 'managed_file' element type.
*
*
...
@@ -156,6 +158,21 @@ public function testManagedFileRemoved() {
...
@@ -156,6 +158,21 @@ public function testManagedFileRemoved() {
$this
->
assertRaw
(
'The file referenced by the Managed <em>file & butter</em> field does not exist.'
);
$this
->
assertRaw
(
'The file referenced by the Managed <em>file & butter</em> field does not exist.'
);
}
}
/**
* Tests file names have leading . removed.
*/
public
function
testFileNameTrim
()
{
file_put_contents
(
'public://.leading-period.txt'
,
$this
->
randomString
(
32
));
$last_fid_prior
=
$this
->
getLastFileId
();
$this
->
drupalPostForm
(
'file/test/0/0/0'
,
[
'files[file]'
=>
\Drupal
::
service
(
'file_system'
)
->
realpath
(
'public://.leading-period.txt'
),
],
t
(
'Save'
));
$next_fid
=
$this
->
getLastFileId
();
$this
->
assertGreaterThan
(
$last_fid_prior
,
$next_fid
);
$file
=
File
::
load
(
$next_fid
);
$this
->
assertEquals
(
'leading-period.txt'
,
$file
->
getFilename
());
}
/**
/**
* Ensure a file entity can be saved when the file does not exist on disk.
* Ensure a file entity can be saved when the file does not exist on disk.
*/
*/
...
...
This diff is collapsed.
Click to expand it.
Lee Rowlands
@larowlan
mentioned in commit
b2fd983e
·
Dec 18, 2019
mentioned in commit
b2fd983e
mentioned in commit b2fd983e3d0690588f97e6977bcd3e164e552619
Toggle commit list
Lee Rowlands
@larowlan
mentioned in commit
d1754975
·
Dec 18, 2019
mentioned in commit
d1754975
mentioned in commit d17549754435509d341b2e69e4b49b79b5498ea9
Toggle commit list
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment