Download & Extend

do file test against remote file by url not path?

Project:jQuery Update
Version:5.x-2.0
Component:Code
Category:feature request
Priority:minor
Assigned:Unassigned
Status:active

Issue Summary

In an attempt to avoid changing drupal core, I used a rewrite in httpd.conf to redirect to serve from module misc folder.

If done properly I should not have to wory about corrupting core or updates, nor multisites not using the module.

HOWEVER the module's install file runs a test comparing the files by path, not by url.
In jquery_update.install, could we change the conditional line, below to test by the file retrieved by http... so it tests the redirect instead of hard path? not sure the elegant way to do the md5_file() on a url.
Problem with the below is that it requires this in php.ini
allow_url_fopen = On

if (file_exists($path) && file_exists('misc/jquery.js') && md5_file($path) != md5_file('misc/jquery.js')) {

change to something like

if (file_exists($path) && file_exists('misc/jquery.js') && md5_file($path) != md5_file('http://mywebsite.com/misc/jquery.js')) {

Note according to php site, as of 5.1.0, md5_file() Changed the function to use the streams API. It means that you can use it with wrappers, like md5_file('http://example.com/..') but, we are using "remote files" and many servers will complain.... php.ini setting...

thoughts ?

else those doing the above just hack the jquery_update.install test.

------------------

Example of rewrite commands, after the rewrite base directive:

RewriteRule ^misc.collapse.js$ sites/all/modules/jquery_update/misc/collapse.js [L,QSA]
RewriteRule ^misc.farbtastic.farbtastic.js$ sites/all/modules/jquery_update/misc/farbtastic/farbtastic.js [L,QSA]
RewriteRule ^misc.jquery.js$ sites/all/modules/jquery_update/misc/jquery.js [L,QSA]
RewriteRule ^misc.tableselect.js$ sites/all/modules/jquery_update/misc/tableselect.js [L,QSA]
RewriteRule ^misc.upload.js$ sites/all/modules/jquery_update/misc/upload.js [L,QSA]

It could have been done in .htaccess also but I'd have to put rulecond.
see http://justinhileman.info/blog/2008/04/jquery-update-in-a-multisite-drup...

Comments

#1

or something like this but add test for injection ?

$siteHostName = getenv('HTTP_HOST');
$sitejaddress = "http://" . $siteHostName . "/misc/jquery.js";
if (file_exists($path) && file_exists('misc/jquery.js') && md5_file($path) != md5_file($sitejaddress)) {

nobody click here