summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Biebl <mbiebl@src.gnome.org>2007-11-24 01:15:12 +0000
committerMichael Biebl <mbiebl@src.gnome.org>2007-11-24 01:15:12 +0000
commite66c84791c1dc64597dec4f18ff6b1882a99895e (patch)
tree9fd2dded292e18718bf21f987c78338ff806ac90
parentf4f80953bde69c2115488716137ff4b638f47068 (diff)
downloadtracker-e66c84791c1dc64597dec4f18ff6b1882a99895e.tar.gz
Fix the shell scripts for the external filters
- Use mktemp to create safe temp files. - Make all scripts respect the TMPDIR environment variable. - Remove unnecessary output to stdout. - Change the working directory of the msword filter before calling wvText to avoid creating temporary files in $HOME. svn path=/trunk/; revision=1042
-rw-r--r--ChangeLog10
-rwxr-xr-xfilters/application/csv_filter12
-rwxr-xr-xfilters/application/msword_filter24
-rwxr-xr-xfilters/application/pdf_filter1
-rwxr-xr-xfilters/application/tab-separated-values_filter12
-rwxr-xr-xfilters/application/vnd.ms-excel_filter12
-rwxr-xr-xfilters/application/vnd.oasis.opendocument.presentation-template_filter2
-rwxr-xr-xfilters/application/vnd.oasis.opendocument.presentation_filter2
-rwxr-xr-xfilters/application/vnd.oasis.opendocument.spreadsheet-template_filter2
-rwxr-xr-xfilters/application/vnd.oasis.opendocument.spreadsheet_filter2
-rwxr-xr-xfilters/application/vnd.oasis.opendocument.text_filter2
-rwxr-xr-xfilters/application/vnd.stardivision.writer_filter2
-rwxr-xr-xfilters/application/vnd.sun.xml.calc.template_filter2
-rwxr-xr-xfilters/application/vnd.sun.xml.calc_filter2
-rwxr-xr-xfilters/application/vnd.sun.xml.draw_filter2
-rwxr-xr-xfilters/application/vnd.sun.xml.impress.template_filter2
-rwxr-xr-xfilters/application/vnd.sun.xml.impress_filter2
-rwxr-xr-xfilters/application/vnd.sun.xml.writer_filter2
-rwxr-xr-xfilters/application/x-abiword_filter1
-rwxr-xr-xfilters/application/x-gnumeric_filter12
-rwxr-xr-xfilters/text/csv_filter12
-rwxr-xr-xfilters/text/spreadsheet_filter12
-rwxr-xr-xfilters/text/tab-separated-values_filter12
-rwxr-xr-xfilters/text/x-comma-separated-values_filter12
-rwxr-xr-xfilters/text/xml_filter1
25 files changed, 72 insertions, 85 deletions
diff --git a/ChangeLog b/ChangeLog
index 4b8ac06b3..416c956c9 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,13 @@
+2007-11-24 Michael Biebl <mbiebl at gmail com>
+
+ * filters/*/*_filter:
+ Fix the shell scripts for the external filters
+ - Use mktemp to create safe temp files.
+ - Make all scripts respect the TMPDIR environment variable.
+ - Remove unnecessary output to stdout.
+ - Change the working directory of the msword filter before calling
+ wvText to avoid creating temporary files in $HOME.
+
2007-11-23 Saleem Abdulrasool <compnerd@compnerd.org>
* src/tracker-preferences/tracker-preferences.glade:
diff --git a/filters/application/csv_filter b/filters/application/csv_filter
index ff21af5eb..b03bf47fb 100755
--- a/filters/application/csv_filter
+++ b/filters/application/csv_filter
@@ -1,12 +1,10 @@
#!/bin/sh
-umask 077
+tmpfile=`mktemp` || exit 1
-st=/tmp/tempfile.$$
+nice -n19 ssindex -i "$1" > "$tmpfile"
-nice -n19 ssindex -i "$1" > st
-
-nice -n19 xsltproc - st > "$2" <<EOF
+nice -n19 xsltproc - "$tmpfile" > "$2" <<EOF
<?xml version="1.0"?>
<xsl:stylesheet
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
@@ -22,6 +20,4 @@ nice -n19 xsltproc - st > "$2" <<EOF
</xsl:stylesheet>
EOF
-rm st
-
-cat "$2"
+rm "$tmpfile"
diff --git a/filters/application/msword_filter b/filters/application/msword_filter
index eb3d52f89..287757b55 100755
--- a/filters/application/msword_filter
+++ b/filters/application/msword_filter
@@ -1,8 +1,20 @@
#!/bin/sh
-umask 077
-cp "$1" /tmp/tempfile.$$
-nice -n19 wvText /tmp/tempfile.$$ "$2"
-rm /tmp/tempfile.$$
-# remove temporary included image files left by wvText
-rm `pwd "$2"`/tempfile.$$*
+tmpdir=${TMPDIR-/tmp}
+tmpdir="$tmpdir"/tmpdir.$$
+
+(umask 077 && mkdir "$tmpdir") || exit 1
+
+tmpfile="$tmpdir"/tmpfile.$$
+
+cp "$1" "$tmpfile"
+
+# Change the working directory to $tmpdir which we can safely deleter later.
+# Some distributions ship a version of wvText which extracts the image files
+# from the word document and places them in the current working directory.
+
+cd "$tmpdir"
+
+nice -n19 wvText "$tmpfile" "$2"
+
+rm -rf "$tmpdir"
diff --git a/filters/application/pdf_filter b/filters/application/pdf_filter
index 0fad15bf4..a972b0c1e 100755
--- a/filters/application/pdf_filter
+++ b/filters/application/pdf_filter
@@ -1,4 +1,3 @@
#!/bin/sh
nice -n19 pdftotext -enc UTF-8 -q -nopgbrk "$1" "$2"
-
diff --git a/filters/application/tab-separated-values_filter b/filters/application/tab-separated-values_filter
index ff21af5eb..b03bf47fb 100755
--- a/filters/application/tab-separated-values_filter
+++ b/filters/application/tab-separated-values_filter
@@ -1,12 +1,10 @@
#!/bin/sh
-umask 077
+tmpfile=`mktemp` || exit 1
-st=/tmp/tempfile.$$
+nice -n19 ssindex -i "$1" > "$tmpfile"
-nice -n19 ssindex -i "$1" > st
-
-nice -n19 xsltproc - st > "$2" <<EOF
+nice -n19 xsltproc - "$tmpfile" > "$2" <<EOF
<?xml version="1.0"?>
<xsl:stylesheet
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
@@ -22,6 +20,4 @@ nice -n19 xsltproc - st > "$2" <<EOF
</xsl:stylesheet>
EOF
-rm st
-
-cat "$2"
+rm "$tmpfile"
diff --git a/filters/application/vnd.ms-excel_filter b/filters/application/vnd.ms-excel_filter
index ff21af5eb..b03bf47fb 100755
--- a/filters/application/vnd.ms-excel_filter
+++ b/filters/application/vnd.ms-excel_filter
@@ -1,12 +1,10 @@
#!/bin/sh
-umask 077
+tmpfile=`mktemp` || exit 1
-st=/tmp/tempfile.$$
+nice -n19 ssindex -i "$1" > "$tmpfile"
-nice -n19 ssindex -i "$1" > st
-
-nice -n19 xsltproc - st > "$2" <<EOF
+nice -n19 xsltproc - "$tmpfile" > "$2" <<EOF
<?xml version="1.0"?>
<xsl:stylesheet
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
@@ -22,6 +20,4 @@ nice -n19 xsltproc - st > "$2" <<EOF
</xsl:stylesheet>
EOF
-rm st
-
-cat "$2"
+rm "$tmpfile"
diff --git a/filters/application/vnd.oasis.opendocument.presentation-template_filter b/filters/application/vnd.oasis.opendocument.presentation-template_filter
index 5c709474b..4024891c4 100755
--- a/filters/application/vnd.oasis.opendocument.presentation-template_filter
+++ b/filters/application/vnd.oasis.opendocument.presentation-template_filter
@@ -1,3 +1,3 @@
#!/bin/sh
- nice -n19 unzip -p "$1" content.xml | o3totxt > "$2"
+nice -n19 unzip -p "$1" content.xml | o3totxt > "$2"
diff --git a/filters/application/vnd.oasis.opendocument.presentation_filter b/filters/application/vnd.oasis.opendocument.presentation_filter
index 5c709474b..4024891c4 100755
--- a/filters/application/vnd.oasis.opendocument.presentation_filter
+++ b/filters/application/vnd.oasis.opendocument.presentation_filter
@@ -1,3 +1,3 @@
#!/bin/sh
- nice -n19 unzip -p "$1" content.xml | o3totxt > "$2"
+nice -n19 unzip -p "$1" content.xml | o3totxt > "$2"
diff --git a/filters/application/vnd.oasis.opendocument.spreadsheet-template_filter b/filters/application/vnd.oasis.opendocument.spreadsheet-template_filter
index 5c709474b..4024891c4 100755
--- a/filters/application/vnd.oasis.opendocument.spreadsheet-template_filter
+++ b/filters/application/vnd.oasis.opendocument.spreadsheet-template_filter
@@ -1,3 +1,3 @@
#!/bin/sh
- nice -n19 unzip -p "$1" content.xml | o3totxt > "$2"
+nice -n19 unzip -p "$1" content.xml | o3totxt > "$2"
diff --git a/filters/application/vnd.oasis.opendocument.spreadsheet_filter b/filters/application/vnd.oasis.opendocument.spreadsheet_filter
index 5c709474b..4024891c4 100755
--- a/filters/application/vnd.oasis.opendocument.spreadsheet_filter
+++ b/filters/application/vnd.oasis.opendocument.spreadsheet_filter
@@ -1,3 +1,3 @@
#!/bin/sh
- nice -n19 unzip -p "$1" content.xml | o3totxt > "$2"
+nice -n19 unzip -p "$1" content.xml | o3totxt > "$2"
diff --git a/filters/application/vnd.oasis.opendocument.text_filter b/filters/application/vnd.oasis.opendocument.text_filter
index 5c709474b..4024891c4 100755
--- a/filters/application/vnd.oasis.opendocument.text_filter
+++ b/filters/application/vnd.oasis.opendocument.text_filter
@@ -1,3 +1,3 @@
#!/bin/sh
- nice -n19 unzip -p "$1" content.xml | o3totxt > "$2"
+nice -n19 unzip -p "$1" content.xml | o3totxt > "$2"
diff --git a/filters/application/vnd.stardivision.writer_filter b/filters/application/vnd.stardivision.writer_filter
index 5c709474b..4024891c4 100755
--- a/filters/application/vnd.stardivision.writer_filter
+++ b/filters/application/vnd.stardivision.writer_filter
@@ -1,3 +1,3 @@
#!/bin/sh
- nice -n19 unzip -p "$1" content.xml | o3totxt > "$2"
+nice -n19 unzip -p "$1" content.xml | o3totxt > "$2"
diff --git a/filters/application/vnd.sun.xml.calc.template_filter b/filters/application/vnd.sun.xml.calc.template_filter
index 5c709474b..4024891c4 100755
--- a/filters/application/vnd.sun.xml.calc.template_filter
+++ b/filters/application/vnd.sun.xml.calc.template_filter
@@ -1,3 +1,3 @@
#!/bin/sh
- nice -n19 unzip -p "$1" content.xml | o3totxt > "$2"
+nice -n19 unzip -p "$1" content.xml | o3totxt > "$2"
diff --git a/filters/application/vnd.sun.xml.calc_filter b/filters/application/vnd.sun.xml.calc_filter
index 5c709474b..4024891c4 100755
--- a/filters/application/vnd.sun.xml.calc_filter
+++ b/filters/application/vnd.sun.xml.calc_filter
@@ -1,3 +1,3 @@
#!/bin/sh
- nice -n19 unzip -p "$1" content.xml | o3totxt > "$2"
+nice -n19 unzip -p "$1" content.xml | o3totxt > "$2"
diff --git a/filters/application/vnd.sun.xml.draw_filter b/filters/application/vnd.sun.xml.draw_filter
index 5c709474b..4024891c4 100755
--- a/filters/application/vnd.sun.xml.draw_filter
+++ b/filters/application/vnd.sun.xml.draw_filter
@@ -1,3 +1,3 @@
#!/bin/sh
- nice -n19 unzip -p "$1" content.xml | o3totxt > "$2"
+nice -n19 unzip -p "$1" content.xml | o3totxt > "$2"
diff --git a/filters/application/vnd.sun.xml.impress.template_filter b/filters/application/vnd.sun.xml.impress.template_filter
index 5c709474b..4024891c4 100755
--- a/filters/application/vnd.sun.xml.impress.template_filter
+++ b/filters/application/vnd.sun.xml.impress.template_filter
@@ -1,3 +1,3 @@
#!/bin/sh
- nice -n19 unzip -p "$1" content.xml | o3totxt > "$2"
+nice -n19 unzip -p "$1" content.xml | o3totxt > "$2"
diff --git a/filters/application/vnd.sun.xml.impress_filter b/filters/application/vnd.sun.xml.impress_filter
index 5c709474b..4024891c4 100755
--- a/filters/application/vnd.sun.xml.impress_filter
+++ b/filters/application/vnd.sun.xml.impress_filter
@@ -1,3 +1,3 @@
#!/bin/sh
- nice -n19 unzip -p "$1" content.xml | o3totxt > "$2"
+nice -n19 unzip -p "$1" content.xml | o3totxt > "$2"
diff --git a/filters/application/vnd.sun.xml.writer_filter b/filters/application/vnd.sun.xml.writer_filter
index 5c709474b..4024891c4 100755
--- a/filters/application/vnd.sun.xml.writer_filter
+++ b/filters/application/vnd.sun.xml.writer_filter
@@ -1,3 +1,3 @@
#!/bin/sh
- nice -n19 unzip -p "$1" content.xml | o3totxt > "$2"
+nice -n19 unzip -p "$1" content.xml | o3totxt > "$2"
diff --git a/filters/application/x-abiword_filter b/filters/application/x-abiword_filter
index 4042a6fee..a1fbe6356 100755
--- a/filters/application/x-abiword_filter
+++ b/filters/application/x-abiword_filter
@@ -15,4 +15,3 @@ nice -n19 xsltproc - "$1" > "$2" <<EOF
</xsl:stylesheet>
EOF
-
diff --git a/filters/application/x-gnumeric_filter b/filters/application/x-gnumeric_filter
index ff21af5eb..b03bf47fb 100755
--- a/filters/application/x-gnumeric_filter
+++ b/filters/application/x-gnumeric_filter
@@ -1,12 +1,10 @@
#!/bin/sh
-umask 077
+tmpfile=`mktemp` || exit 1
-st=/tmp/tempfile.$$
+nice -n19 ssindex -i "$1" > "$tmpfile"
-nice -n19 ssindex -i "$1" > st
-
-nice -n19 xsltproc - st > "$2" <<EOF
+nice -n19 xsltproc - "$tmpfile" > "$2" <<EOF
<?xml version="1.0"?>
<xsl:stylesheet
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
@@ -22,6 +20,4 @@ nice -n19 xsltproc - st > "$2" <<EOF
</xsl:stylesheet>
EOF
-rm st
-
-cat "$2"
+rm "$tmpfile"
diff --git a/filters/text/csv_filter b/filters/text/csv_filter
index ff21af5eb..b03bf47fb 100755
--- a/filters/text/csv_filter
+++ b/filters/text/csv_filter
@@ -1,12 +1,10 @@
#!/bin/sh
-umask 077
+tmpfile=`mktemp` || exit 1
-st=/tmp/tempfile.$$
+nice -n19 ssindex -i "$1" > "$tmpfile"
-nice -n19 ssindex -i "$1" > st
-
-nice -n19 xsltproc - st > "$2" <<EOF
+nice -n19 xsltproc - "$tmpfile" > "$2" <<EOF
<?xml version="1.0"?>
<xsl:stylesheet
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
@@ -22,6 +20,4 @@ nice -n19 xsltproc - st > "$2" <<EOF
</xsl:stylesheet>
EOF
-rm st
-
-cat "$2"
+rm "$tmpfile"
diff --git a/filters/text/spreadsheet_filter b/filters/text/spreadsheet_filter
index ff21af5eb..b03bf47fb 100755
--- a/filters/text/spreadsheet_filter
+++ b/filters/text/spreadsheet_filter
@@ -1,12 +1,10 @@
#!/bin/sh
-umask 077
+tmpfile=`mktemp` || exit 1
-st=/tmp/tempfile.$$
+nice -n19 ssindex -i "$1" > "$tmpfile"
-nice -n19 ssindex -i "$1" > st
-
-nice -n19 xsltproc - st > "$2" <<EOF
+nice -n19 xsltproc - "$tmpfile" > "$2" <<EOF
<?xml version="1.0"?>
<xsl:stylesheet
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
@@ -22,6 +20,4 @@ nice -n19 xsltproc - st > "$2" <<EOF
</xsl:stylesheet>
EOF
-rm st
-
-cat "$2"
+rm "$tmpfile"
diff --git a/filters/text/tab-separated-values_filter b/filters/text/tab-separated-values_filter
index ff21af5eb..b03bf47fb 100755
--- a/filters/text/tab-separated-values_filter
+++ b/filters/text/tab-separated-values_filter
@@ -1,12 +1,10 @@
#!/bin/sh
-umask 077
+tmpfile=`mktemp` || exit 1
-st=/tmp/tempfile.$$
+nice -n19 ssindex -i "$1" > "$tmpfile"
-nice -n19 ssindex -i "$1" > st
-
-nice -n19 xsltproc - st > "$2" <<EOF
+nice -n19 xsltproc - "$tmpfile" > "$2" <<EOF
<?xml version="1.0"?>
<xsl:stylesheet
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
@@ -22,6 +20,4 @@ nice -n19 xsltproc - st > "$2" <<EOF
</xsl:stylesheet>
EOF
-rm st
-
-cat "$2"
+rm "$tmpfile"
diff --git a/filters/text/x-comma-separated-values_filter b/filters/text/x-comma-separated-values_filter
index ff21af5eb..b03bf47fb 100755
--- a/filters/text/x-comma-separated-values_filter
+++ b/filters/text/x-comma-separated-values_filter
@@ -1,12 +1,10 @@
#!/bin/sh
-umask 077
+tmpfile=`mktemp` || exit 1
-st=/tmp/tempfile.$$
+nice -n19 ssindex -i "$1" > "$tmpfile"
-nice -n19 ssindex -i "$1" > st
-
-nice -n19 xsltproc - st > "$2" <<EOF
+nice -n19 xsltproc - "$tmpfile" > "$2" <<EOF
<?xml version="1.0"?>
<xsl:stylesheet
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
@@ -22,6 +20,4 @@ nice -n19 xsltproc - st > "$2" <<EOF
</xsl:stylesheet>
EOF
-rm st
-
-cat "$2"
+rm "$tmpfile"
diff --git a/filters/text/xml_filter b/filters/text/xml_filter
index 4042a6fee..a1fbe6356 100755
--- a/filters/text/xml_filter
+++ b/filters/text/xml_filter
@@ -15,4 +15,3 @@ nice -n19 xsltproc - "$1" > "$2" <<EOF
</xsl:stylesheet>
EOF
-