Hi

Running Apache/2.2.11 (Win32) PHP/5.2.9-1 on Server 2003 SP2.

When cron runs, the Recent log entries window is filled with "Could not extract any indexable text from" followed by the file name & path to the attached file.

It would seem that "escapeshellcmd" is misbehaving, though I'm not sure how to fix it (or describe it). If, at line 323 (or thereabouts) I remove that function call, the files get read and indexed.

Capturing the value of $cmd, with the function call in place I see:

	java -cp D: websites drupal6 sites all modules apachesolr_attachments tika -jar D: websites drupal6 sites all modules apachesolr_attachments tika/tika-0.3.jar -t D: websites drupal6 sites wiki.cfertech.com files CS4 Design Premium Read Me.pdf 

With the function call removed:

	java -cp D:\websites\drupal6\sites\all\modules\apachesolr_attachments\tika -jar D:\websites\drupal6\sites\all\modules\apachesolr_attachments\tika/tika-0.3.jar -t "D:\websites\drupal6\sites\wiki.cfertech.com\files\CS4 Design Premium Read Me.pdf"

Comments

dgarciad’s picture

Hi

I think the problem is related to using "\" instead of "/" as it happens in windows.

I have also commented the escapeshellcmd:

// $cmd = escapeshellcmd($java .' -cp '. $tika_path .' -jar '. $tika .' -t "'. $filepath .'"');
$cmd = $java .' -cp '. $tika_path .' -jar '. $tika .' -t "'. $filepath .'"';

Maybe relacing every "\" with "/" will avoid troubles:

$cmd_tmp = $java .' -cp '. $tika_path .' -jar '. $tika .' -t "'. $filepath .'"';
$cmd = str_replace('\\', '/', $cmd_tmp);

Regards

cyberguyen’s picture

Version: 6.x-2.x-dev » 6.x-2.0-alpha1

As dgarciad suggest:

// $cmd = escapeshellcmd($java .' -cp '. $tika_path .' -jar '. $tika .' -t "'. $filepath .'"');

$cmd_tmp = $java .' -cp '. $tika_path .' -jar '. $tika .' -t "'. $filepath .'"';
$cmd = str_replace('\\', '/', $cmd_tmp);

This works very well on my windows installation of drupal so I would like the developer to implement something like it in the next release of Apache Solr Attachments.

pwolanin’s picture

@cyberguyen - patch?

pwolanin’s picture

Why don't you just put your file paths in with forward slashes?

pwolanin’s picture

ah:

On windows realpath() will change unix style paths to windows style.

pwolanin’s picture

Status: Active » Needs review
StatusFileSize
new984 bytes

something like this maybe?

pwolanin’s picture

StatusFileSize
new2.6 KB

Actually - is that right? we want to maybe just escape the cmd and not the paths if they passed through realpath()?

Is there a danger with filename containing an &? At least in may case seems ok if the filename is in "" marks.

pwolanin’s picture

Any feedback on this patch? I don't have java set up on windows ATM.

pwolanin’s picture

Version: 6.x-2.0-alpha1 » 6.x-2.x-dev
StatusFileSize
new2.39 KB

updated patch to match changes in CVS.

pwolanin’s picture

StatusFileSize
new2.27 KB

Heine pointed me to http://www.php.net/manual/en/function.escapeshellarg.php so let's try with that.

pwolanin’s picture

Title: Getting "Could not extract any indexable text from..." on all attachments » Preserve file paths on windows
Status: Needs review » Fixed

Committed to HEAD

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.