#!/bin/sh # "detect-svg-leakage" detects whether SVG files in the working # directory have attributes with local path name values, and prints # such attributes and their values. # The script (or a soft link to it) should be placed in the directory # containing the SVG files. It may be run either from the graphical user # interface (see "anonymize-svg"), or from the command line without argument. # In both cases, it will examine the SVG files in the directory and will # print their names, and the attributes whose value may be a local file # system path or a sensitive file name. # Copyright (C) 2014 Donatas KlimaĊĦauskas # You may redistribute this script and/or modify it under the terms of the # Creative Commons CC0 license # (http://creativecommons.org/publicdomain/zero/1.0/legalcode). set -e close_term () { printf '\n%s' '*** Close the terminal window or press Return.'; read OK test -z "$OK" && exit $1 } for svg in *.svg; do test -s "$svg" \ || (echo "*** This directory doesn't contain any SVG."; close_term '1') printf '\n%s\n\n' "=== $svg" perl -Twe 'while (<>) { print "$1\n" if m/([\w\-:]+="([\/\.]+|file:).+?"|[\w:]+docname=".+")/i; }' <"$svg"; done close_term '0'