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
3b27f61f
Verified
Commit
3b27f61f
authored
6 years ago
by
href
Browse files
Options
Downloads
Patches
Plain Diff
AnonymizeFilename: allow for a pre-defined text instead of random string
Improve docs
parent
8764f646
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
config/config.md
+11
-0
11 additions, 0 deletions
config/config.md
lib/pleroma/upload/filter/anonymize_filename.ex
+16
-3
16 additions, 3 deletions
lib/pleroma/upload/filter/anonymize_filename.ex
with
27 additions
and
3 deletions
config/config.md
+
11
−
0
View file @
3b27f61f
...
...
@@ -19,6 +19,17 @@ Note: `strip_exif` has been replaced by `Pleroma.Upload.Filter.Mogrify`.
*
`args`
: List of actions for the
`mogrify`
command like
`"strip"`
or
`["strip", {"impode", "1"}]`
.
## Pleroma.Upload.Filter.Dedupe
No specific configuration.
## Pleroma.Upload.Filter.AnonymizeFilename
This filter remplaces the filename (not the path) of an upload. For complete obfuscation, add
`Pleroma.Upload.Filter.Dedupe`
before AnonymizeFilename.
*
`text`
: Text to remplace filenames in links. If empty,
`{random}.extension`
will be used.
## :uri_schemes
*
`valid_schemes`
: List of the scheme part that is considered valid to be an URL
...
...
This diff is collapsed.
Click to expand it.
lib/pleroma/upload/filter/anonymize_filename.ex
+
16
−
3
View file @
3b27f61f
defmodule
Pleroma
.
Upload
.
Filter
.
AnonymizeFilename
do
@moduledoc
"Replaces the original filename with a randomly generated string."
@moduledoc
"""
Replaces the original filename with a pre-defined text or randomly generated string.
Should be used after `Pleroma.Upload.Filter.Dedupe`.
"""
@behaviour
Pleroma
.
Upload
.
Filter
def
filter
(
upload
)
do
extension
=
List
.
last
(
String
.
split
(
upload
.
name
,
"."
))
string
=
Base
.
url_encode64
(
:crypto
.
strong_rand_bytes
(
10
),
padding:
false
)
{
:ok
,
%
Pleroma
.
Upload
{
upload
|
name:
string
<>
"."
<>
extension
}}
name
=
Pleroma
.
Config
.
get
([
__MODULE__
,
:text
],
random
(
extension
))
{
:ok
,
%
Pleroma
.
Upload
{
upload
|
name:
name
}}
end
defp
random
(
extension
)
do
string
=
10
|>
:crypto
.
strong_rand_bytes
()
|>
Base
.
url_encode64
(
padding:
false
)
string
<>
"."
<>
extension
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