Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
P
pleroma
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
jeff
pleroma
Commits
f20bfc9e
Commit
f20bfc9e
authored
6 years ago
by
rinpatch
Browse files
Options
Downloads
Plain Diff
Merge branch 'media-url-escape' into 'develop'
URI escape file upload URLs See merge request
pleroma/pleroma!665
parents
fd2f1258
dcbe5bd5
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
lib/pleroma/upload.ex
+1
-1
1 addition, 1 deletion
lib/pleroma/upload.ex
test/upload_test.exs
+15
-0
15 additions, 0 deletions
test/upload_test.exs
with
16 additions
and
1 deletion
lib/pleroma/upload.ex
+
1
−
1
View file @
f20bfc9e
...
...
@@ -215,7 +215,7 @@ defmodule Pleroma.Upload do
end
defp
url_from_spec
(
base_url
,
{
:file
,
path
})
do
[
base_url
,
"media"
,
path
]
[
base_url
,
"media"
,
URI
.
encode
(
path
)
]
|>
Path
.
join
()
end
...
...
This diff is collapsed.
Click to expand it.
test/upload_test.exs
+
15
−
0
View file @
f20bfc9e
...
...
@@ -137,5 +137,20 @@ defmodule Pleroma.UploadTest do
refute
data
[
"name"
]
==
"an [image.jpg"
end
test
"escapes invalid characters in url"
do
File
.
cp!
(
"test/fixtures/image.jpg"
,
"test/fixtures/image_tmp.jpg"
)
file
=
%
Plug
.
Upload
{
content_type:
"image/jpg"
,
path:
Path
.
absname
(
"test/fixtures/image_tmp.jpg"
),
filename:
"an… image.jpg"
}
{
:ok
,
data
}
=
Upload
.
store
(
file
)
[
attachment_url
|
_
]
=
data
[
"url"
]
assert
Path
.
basename
(
attachment_url
[
"href"
])
==
"an%E2%80%A6%20image.jpg"
end
end
end
This diff is collapsed.
Click to expand it.
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