Skip to content

Commit

Permalink
invalid characters: differ only win32 and other
Browse files Browse the repository at this point in the history
  • Loading branch information
norbertwg committed Nov 27, 2024
1 parent 913b495 commit 894e0fe
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 6 deletions.
6 changes: 1 addition & 5 deletions app/actions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1851,12 +1851,8 @@ int renameFile(std::string& newPath, const tm* tm, Exiv2::ExifData& exifData) {
std::regex format_regex(":{1}?(Exif\\..*?):{1}?");
#if defined(_WIN32)
std::string illegalChars = "\\/:*?\"<>|";
/* Todo: How to correctly recognize a Mac platform? */
#elif defined macintosh || defined MACOS_CLASSIC || defined MACOS_X_UNIX || defined MACOS_X || defined MACOS || \
defined(__APPLE__)
std::string illegalChars = "/:";
#else
std::string illegalChars = "/";
std::string illegalChars = "/:";
#endif
std::regex_token_iterator<std::string::iterator> rend;
std::regex_token_iterator<std::string::iterator> token(format.begin(), format.end(), format_regex);
Expand Down
29 changes: 28 additions & 1 deletion tests/bash_tests/test_rename.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# -*- coding: utf-8 -*-

import sys
from system_tests import CaseMeta, CopyFiles, CopyTmpFiles, DeleteFiles, path

###########################################################
Expand Down Expand Up @@ -73,7 +74,11 @@ class Rename_ExifTags(metaclass=CaseMeta):
###########################################################

infile ="_DSC8437.exv"
outfile = "_DSC8437_a_b_c_d_e_f_g_h_i.exv"
if sys.platform == 'win32':
outfile = "_DSC8437_a_b_c_d_e_f_g_h_i.exv"
else:
outfile = "_DSC8437_a\\b_c_d*e?f<g>h|i.exv"

renformat = ":basename:_:Exif.Image.ImageDescription:"

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

###########################################################
# rename error: invalid tag name
###########################################################

infile ="_DSC8437.exv"
renformat = ":basename:_:Exif.Image.ImageDescript:"

@CopyTmpFiles("$data_path/" + infile)
class Rename_InvalidTagName(metaclass=CaseMeta):
infilename = path("$tmp_path/" + infile)
commands = [
"$exiv2 --verbose --rename " + renformat + " " + infilename
]
stdout = [
"""File 1/1: $infilename
"""
]
stderr = ["""Exiv2 exception in rename action for file $infilename:
Invalid tag name or ifdId `ImageDescript', ifdId 1
"""]
retval = [1] * len(commands)

###########################################################
# rename error: file contains no Exif data
###########################################################
Expand Down

0 comments on commit 894e0fe

Please sign in to comment.