Re: [SMARTY-DEV] Problem with custom resource compiled filenames

From: Date: Mon, 22 Aug 2005 12:19:32 +0000
Subject: Re: [SMARTY-DEV] Problem with custom resource compiled filenames
References: 1 2 3 4  Groups: php.smarty.dev 
Request: Send a blank email to php-smarty-dev+get-2766@lists.php.net to get a copy of this message
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Hi, Ivo Jansch wrote: >>>how would you handle the case that the filenames is invalid just >>>because it is too long? > I was thinking of generating a 32-character hash. 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 . 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-----

« previous php.smarty.dev (#2766) next »