[postprocessor:metadata] sanitize filenames

pull/1253/head
Mike Fährmann 4 years ago
parent 32fcc61b84
commit 0fdaea00a3
No known key found for this signature in database
GPG Key ID: 5680CA389D365A88

@ -1,5 +1,7 @@
# Changelog
## Unreleased
## 1.16.2 - 2021-01-09
### Additions
- [derpibooru] add `search` and `gallery` extractors ([#862](https://github.com/mikf/gallery-dl/issues/862))

@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
# Copyright 2019-2020 Mike Fährmann
# Copyright 2019-2021 Mike Fährmann
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License version 2 as
@ -86,7 +86,8 @@ class MetadataPP(PostProcessor):
return (pathfmt.filename or "metadata") + "." + self.extension
def _filename_custom(self, pathfmt):
return self._filename_fmt(pathfmt.kwdict)
return pathfmt.clean_path(pathfmt.clean_segment(
self._filename_fmt(pathfmt.kwdict)))
def _filename_extfmt(self, pathfmt):
kwdict = pathfmt.kwdict

@ -6,4 +6,4 @@
# it under the terms of the GNU General Public License version 2 as
# published by the Free Software Foundation.
__version__ = "1.16.2"
__version__ = "1.16.3-dev"

@ -306,14 +306,14 @@ class MetadataTest(BasePostprocessorTest):
def test_metadata_filename(self):
self._create({
"filename" : "{category}_{filename}_meta.data",
"filename" : "{category}_{filename}_/meta/\n\r.data",
"extension-format": "json",
})
with patch("builtins.open", mock_open()) as m:
self._trigger()
path = self.pathfmt.realdirectory + "test_file_meta.data"
path = self.pathfmt.realdirectory + "test_file__meta_.data"
m.assert_called_once_with(path, "w", encoding="utf-8")
@staticmethod

Loading…
Cancel
Save