? Untitled-2
? dump.tcp
? escape-506526-9.patch
? icons
? kkk{ass
? schema-rc4-664154-1.patch
? schema-rc4-664154-2.patch
? test.txt
Index: apachesolr_attachments.admin.inc
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/apachesolr_attachments/apachesolr_attachments.admin.inc,v
retrieving revision 1.2
diff -u -p -r1.2 apachesolr_attachments.admin.inc
--- apachesolr_attachments.admin.inc	20 Dec 2009 02:15:51 -0000	1.2
+++ apachesolr_attachments.admin.inc	20 Dec 2009 02:37:27 -0000
@@ -354,10 +354,16 @@ function apachesolr_attachments_get_cck_
 
 /**
  * Parse the attachment getting just the raw text.
+ *
+ * @throws Exception
  */
 function apachesolr_attachments_get_attachment_text($file) {
   // Any down-side to using realpath()?
   $filepath = realpath($file->filepath);
+  // Check that we have a valid filepath.
+  if (!($filepath) || !is_file($filepath)) {
+    return FALSE;
+  }
 
   // No need to use java for plain text files.
   if ($file->filemime == 'text/plain' || $file->filemime == 'text/x-diff') {
@@ -401,18 +407,25 @@ function apachesolr_attachments_get_atta
 
 /**
  * For a file path, try to extract text using a local tika jar.
+ *
+ * @throws Exception
  */
 function apachesolr_attachments_extract_using_tika($filepath) {
   $tika_path = realpath(variable_get('apachesolr_attachments_tika_path', ''));
 
-  $tika = $tika_path .'/'. variable_get('apachesolr_attachments_tika_jar', 'tika-0.3.jar');
+  $tika = realpath($tika_path .'/'. variable_get('apachesolr_attachments_tika_jar', 'tika-0.3.jar'));
+  if (!($tika) || !is_file($tika)) {
+    throw new Exception(t('Invalid path or filename for tika application jar.'));
+  }
 
   $java = variable_get('apachesolr_attachments_java', 'java');
   // By default force UTF-8 output.
   $java_opts = ' ' . variable_get('apachesolr_attachments_java_opts', '-Dfile.encoding=UTF8');
-  $cmd = escapeshellcmd($java . $java_opts .' -cp '. $tika_path .' -jar '. $tika .' -t "'. $filepath .'"');
+  // Escape quote marks in the file name.
+  $filepath = str_replace('"', '\\"', $filepath);
+  $cmd = escapeshellcmd($java . $java_opts) .' -cp "'. $tika_path .'" -jar "'. $tika .'" -t "'. $filepath .'"';
 
-  // Add a work-around for a MAMP bug.
+  // Add a work-around for a MAMP bug + java 1.5.
   if (strpos(ini_get('extension_dir'), 'MAMP/')) {
     $cmd = 'export DYLD_LIBRARY_PATH=""; '. $cmd;
   }
