From 0725eab34f5bdd9b0d9c4bc24b39a6b00a72e7d1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mike=20F=C3=A4hrmann?= Date: Mon, 28 Apr 2025 09:42:16 +0200 Subject: [PATCH] [deviantart] unescape `\'` in JSON data (#6653) https://github.com/mikf/gallery-dl/issues/6653#issuecomment-2833783238 --- gallery_dl/extractor/deviantart.py | 4 +++- test/results/deviantart.py | 13 +++++++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/gallery_dl/extractor/deviantart.py b/gallery_dl/extractor/deviantart.py index ae475e2d..37f57fe5 100644 --- a/gallery_dl/extractor/deviantart.py +++ b/gallery_dl/extractor/deviantart.py @@ -868,7 +868,9 @@ x2="45.4107524%" y2="71.4898596%" id="app-root-3">\ yield self.api.deviation(deviation_uuid) def _unescape_json(self, json): - return json.replace('\\"', '"').replace("\\\\", "\\") + return json.replace('\\"', '"') \ + .replace("\\'", "'") \ + .replace("\\\\", "\\") class DeviantartUserExtractor(DeviantartExtractor): diff --git a/test/results/deviantart.py b/test/results/deviantart.py index be447f8f..80eadcaa 100644 --- a/test/results/deviantart.py +++ b/test/results/deviantart.py @@ -942,6 +942,19 @@ __tests__ = ( "num" : range(1, 4), }, +{ + "#url" : "https://www.deviantart.com/exusiasword/art/Zenith-and-Silpha-combo-1186254616", + "#comment" : "JSON escapes in 'additionalMedia' (#6653)", + "#category": ("", "deviantart", "deviation"), + "#class" : deviantart.DeviantartDeviationExtractor, + "#archive" : False, + "#pattern" : ( + r"https://wixmp-ed30a86b8c4ca887773594c2.wixmp.com/f/54e06808-f21d-4b8d-bd48-bdea03cf0af5/djm9jx4-23fc1032-ee0d-460b-ac52-fcdf5e871317\.jpg\?token=ey.+", + r"https://images-wixmp-ed30a86b8c4ca887773594c2.wixmp.com/f/54e06808-f21d-4b8d-bd48-bdea03cf0af5/djm9jx4-7710b540-c27c-41f2-ae84-9d050ec170bc\.png\?token=ey.+", + r"https://images-wixmp-ed30a86b8c4ca887773594c2.wixmp.com/f/54e06808-f21d-4b8d-bd48-bdea03cf0af5/djm9jx4-e04525ea-b781-451a-ae70-b66243417868\.png\?token=ey.+", + ), +}, + { "#url" : "https://deviantart.com/view/904858796/", "#comment" : "/view/ URLs",