Re: Problem with custom resource compiled filenames

Monte Ohrt <[email protected]> Mon, 22 Aug 2005 11:01:51 -0500
Newsgroups gmane.comp.php.smarty.devel
Message-ID <[email protected]>
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:
>
>  
>
>>>>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 <[email protected]>
>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-----
>
>  
>

-- 
Smarty Development Mailing List (http://smarty.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php