--- tdiary.rb~	Fri Apr  5 19:04:38 2002
+++ tdiary.rb	Mon Apr 22 02:22:41 2002
@@ -319,6 +319,20 @@
 			end
 		end
 
+		def eval_src( src, secure )
+			@body_enter_procs.taint
+			@body_leave_procs.taint
+			if secure
+				th = Thread.start { 
+					$SAFE = 4
+					eval(src)
+				}
+				return th.value
+			else
+				return eval(src)
+			end			
+		end
+
 		def eval_rhtml( rhtml, secure )
 			@body_enter_procs.taint
 			@body_leave_procs.taint
@@ -399,13 +413,14 @@
 				txt
 			}.join
 			r = ERbLight::new( rhtml.untaint ).result( binding )
+			r = ERbLight::new( r ).src
 			save_cache( r, prefix )
 		end
 
 		# apply plugins
 		begin
 			plugin = load_plugins
-			r = plugin.eval_rhtml( r.untaint, @secure ) if plugin
+			r = plugin.eval_src( r.untaint, @secure ) if plugin
 			@cookie = plugin.cookie if plugin.cookie
 		rescue PluginError
 			raise
@@ -607,7 +622,7 @@
 	end
 
 	def clear_cache
-		Dir::glob( "#{cache_path}/*.rhtml" ).each do |c|
+		Dir::glob( "#{cache_path}/*" ).each do |c|
 			File::delete( c.untaint )
 		end
 	end
@@ -1031,7 +1046,7 @@
 
 protected
 	def cache_file( prefix )
-		"#{prefix}#{@rhtml.sub( /month/, @date.strftime( '%Y%m' ) )}"
+		"#{prefix}#{@rhtml.sub( /month/, @date.strftime( '%Y%m' ) ).sub( /\.rhtml$/, '.rb' )}"
 	end
 end
 
@@ -1088,7 +1103,7 @@
 	end
 
 	def cache_file( prefix )
-		"#{prefix}#{@rhtml}"
+		"#{prefix}#{@rhtml.sub( /\.rhtml$/, '.rb' )}"
 	end
 end
 
