Re: More accurate compiled file names

Dmitry Koteroff <[email protected]>
Newsgroups gmane.comp.php.smarty.devel
Message-ID <[email protected]>
Attachment.

-- 
Best regards,
  Dmitry Koteroff.

DK> Hello.

DK> Smarty  saves  its  compiled  code to files with unreadable names
DK> (like  %%23t2763%%sjhdjsdhjshgd.php).  It  makes too difficult to
DK> find  fatal  error in the template (for example, {$obj->spoon()},
DK> where spoon is non-existent method).

DK> Attached patch corrects this problem - it replaces "/" by "^" and
DK> saves the file to temporary location.

DK> Replacement code:

DK> $_filename = preg_replace("{[/\\\\]}s", "^", $_filename);
DK> $_filename = preg_replace("{[^a-z0-9~!_=.^-]}si", "_", $_filename);

DK> Don't you plan to insert this patch to production version?

-- 
Smarty Development Mailing List (http://smarty.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
Smarty_diff.txt (text/plain, 1.4 KB)
--- Distrib.orig/libs/Smarty.class.php	Wed Feb 18 03:00:58 2004
+++ Distrib/libs/Smarty.class.php	Sun May 30 02:23:16 2004
@@ -1791,11 +1791,18 @@
 
         if(isset($auto_source)) {
-            // make source name safe for filename
-            $_filename = urlencode(basename($auto_source));
-            $_crc32 = crc32($auto_source) . $_compile_dir_sep;
-            // prepend %% to avoid name conflicts with
-            // with $params['auto_id'] names
-            $_crc32 = '%%' . substr($_crc32,0,3) . $_compile_dir_sep . '%%' . $_crc32;
-            $_return .= $_crc32 . $_filename;
+            if (0) {
+                // make source name safe for filename
+                $_filename = urlencode(basename($auto_source));
+                $_crc32 = crc32($auto_source) . $_compile_dir_sep;
+                // prepend %% to avoid name conflicts with
+                // with $params['auto_id'] names
+                $_crc32 = '%%' . substr($_crc32,0,3) . $_compile_dir_sep . '%%' . $_crc32;
+                $_return .= $_crc32 . $_filename;
+            } else {
+                $_filename = $auto_source;
+                $_filename = preg_replace("{[/\\\\]}s", "^", $_filename);
+                $_filename = preg_replace("{[^a-z0-9~!_=.^-]}si", "_", $_filename);
+                $_return .= $_filename;
+            }
         }
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.