Re: [SMARTY-DEV] Problem with custom resource compiled filenames
| From: | Monte Ohrt | Date: | Mon, 22 Aug 2005 16:01:51 +0000 |
| Subject: | Re: [SMARTY-DEV] Problem with custom resource compiled filenames | ||
| References: | 1 2 3 4 5 | Groups: | php.smarty.dev |
| Request: | Send a blank email to php-smarty-dev+get-2767@lists.php.net to get a copy of this message | ||
That would be fine with me, although Smarty uses crc32() everywhere instead of md5() since it is 10x faster.
Ivo Jansch wrote:
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Hi, Ivo Jansch wrote:I was able to solve the problem by changing the code in Smarty.class.php to: if(isset($auto_source)) { // make source name safe for filename $_filename = urlencode(basename($auto_source)); $_crc32 = sprintf('%08X', crc32($auto_source)); // prepend %% to avoid name conflicts with // with $params['auto_id'] names $_crc32 = substr($_crc32, 0, 2) . $_compile_dir_sep .I was thinking of generating a 32-character hash.how would you handle the case that the filenames is invalid just because it is too long?substr($_crc32, 0, 3) . $_compile_dir_sep .$_crc32; // Ivo hack.. use hash instead of actual name, if actual name has an // invalid length if (strlen($_filename)>100) { $_filename = md5($_filename); } // end ivo hack $_return .= '%%' . $_crc32 . '%%' . $_filename; } Would you consider modifying this code in the Smarty base code? Greetings, Ivo - -- Ivo Jansch <ivo@ibuildings.nl> ibuildings.nl BV - information technology http://www.ibuildings.nl -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.4 (MingW32) Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org iD8DBQFDCcLT95NUnGFZm9cRAhx7AJ49LZwQr25t7RVFA0CihAfkBOZh/QCdFqu4 OH93xnn/FnT+sZe8SRiA6nU= =CYlR -----END PGP SIGNATURE-----