<commit_before>from subprocess import check_output, CalledProcessError
import json
import re


class Exif(object):
    def __init__(self, file):
        self.file = file

    def data(self):
        try:
            data = check_output('exiftool -time:all -mimetype -j %s' % re.escape(self.file), shell=True).decode('UTF-8')
            exif = json.loads(data)[0]
        except (CalledProcessError, UnicodeDecodeError):
            return None

        return exif<commit_msg>Fix filename quoting when shelling out (#68)<commit_after>from subprocess import check_output, CalledProcessError
import json
import shlex


class Exif(object):
    def __init__(self, file):
        self.file = file

    def data(self):
        try:
            data = check_output('exiftool -time:all -mimetype -j %s' % shlex.quote(self.file), shell=True).decode('UTF-8')
            exif = json.loads(data)[0]
        except (CalledProcessError, UnicodeDecodeError):
            return None

        return exif
{'fraction_non_alphanumeric': 0.10404040404040404, 'fraction_numerical': 0.006060606060606061, 'mean_word_length': 2.7680608365019013, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5162063', 'n_tokens_mistral': 301, 'n_tokens_neox': 290, 'n_words': 77}