Skip to content

Commit c42c755

Browse files
norbertwgkmilos
authored andcommitted
invalid characters: differ only win32 and other
1 parent 1913452 commit c42c755

File tree

2 files changed

+29
-6
lines changed

2 files changed

+29
-6
lines changed

app/actions.cpp

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1836,12 +1836,8 @@ int renameFile(std::string& newPath, const tm* tm, Exiv2::ExifData& exifData) {
18361836
std::regex format_regex(":{1}?(Exif\\..*?):{1}?");
18371837
#if defined(_WIN32)
18381838
std::string illegalChars = "\\/:*?\"<>|";
1839-
/* Todo: How to correctly recognize a Mac platform? */
1840-
#elif defined macintosh || defined MACOS_CLASSIC || defined MACOS_X_UNIX || defined MACOS_X || defined MACOS || \
1841-
defined(__APPLE__)
1842-
std::string illegalChars = "/:";
18431839
#else
1844-
std::string illegalChars = "/";
1840+
std::string illegalChars = "/:";
18451841
#endif
18461842
std::regex_token_iterator<std::string::iterator> rend;
18471843
std::regex_token_iterator<std::string::iterator> token(format.begin(), format.end(), format_regex);

tests/bash_tests/test_rename.py

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
# -*- coding: utf-8 -*-
22

3+
import sys
34
from system_tests import CaseMeta, CopyFiles, CopyTmpFiles, DeleteFiles, path
45

56
###########################################################
@@ -73,7 +74,11 @@ class Rename_ExifTags(metaclass=CaseMeta):
7374
###########################################################
7475

7576
infile ="_DSC8437.exv"
76-
outfile = "_DSC8437_a_b_c_d_e_f_g_h_i.exv"
77+
if sys.platform == 'win32':
78+
outfile = "_DSC8437_a_b_c_d_e_f_g_h_i.exv"
79+
else:
80+
outfile = "_DSC8437_a\\b_c_d*e?f<g>h|i.exv"
81+
7782
renformat = ":basename:_:Exif.Image.ImageDescription:"
7883

7984
@CopyTmpFiles("$data_path/" + infile)
@@ -152,6 +157,28 @@ class Rename_TagNotIncluded(metaclass=CaseMeta):
152157
"""]
153158
retval = [0] * len(commands)
154159

160+
###########################################################
161+
# rename error: invalid tag name
162+
###########################################################
163+
164+
infile ="_DSC8437.exv"
165+
renformat = ":basename:_:Exif.Image.ImageDescript:"
166+
167+
@CopyTmpFiles("$data_path/" + infile)
168+
class Rename_InvalidTagName(metaclass=CaseMeta):
169+
infilename = path("$tmp_path/" + infile)
170+
commands = [
171+
"$exiv2 --verbose --rename " + renformat + " " + infilename
172+
]
173+
stdout = [
174+
"""File 1/1: $infilename
175+
"""
176+
]
177+
stderr = ["""Exiv2 exception in rename action for file $infilename:
178+
Invalid tag name or ifdId `ImageDescript', ifdId 1
179+
"""]
180+
retval = [1] * len(commands)
181+
155182
###########################################################
156183
# rename error: file contains no Exif data
157184
###########################################################

0 commit comments

Comments
 (0)