=== index.rb
==================================================================
--- index.rb	(revision 27329)
+++ index.rb	(local)
@@ -1,11 +1,11 @@
 #!/usr/bin/env ruby
 #
-# index.rb $Revision: 1.35 $
+# index.rb
 #
-# Copyright (C) 2001-2006, TADA Tadashi <sho@spc.gr.jp>
+# Copyright (C) 2001-2008, TADA Tadashi <sho@spc.gr.jp>
 # You can redistribute it and/or modify it under GPL2.
 #
-BEGIN { $defout.binmode }
+BEGIN { $stdout.binmode }
 $KCODE = 'n'
 
 begin
@@ -70,7 +70,7 @@
 			if @cgi.mobile_agent? then
 				body = conf.to_mobile( tdiary.eval_rhtml( 'i.' ) )
 				head['charset'] = conf.mobile_encoding
-				head['Content-Length'] = body.size.to_s
+				head['Content-Length'] = body.bytesize.to_s
 			else
 				require 'digest/md5'
 				body = tdiary.eval_rhtml
@@ -80,7 +80,7 @@
 					body = ''
 				else
 					head['charset'] = conf.encoding
-					head['Content-Length'] = body.size.to_s
+					head['Content-Length'] = body.bytesize.to_s
 				end
 				head['Pragma'] = 'no-cache'
 				head['Cache-Control'] = 'no-cache'
=== plugin/00default.rb
==================================================================
--- plugin/00default.rb	(revision 27329)
+++ plugin/00default.rb	(local)
@@ -697,7 +697,7 @@
 	mail_header = (@conf['comment_mail.header'] || '').dup
 	mail_header << ":#{@conf.date_format}" unless /%[a-zA-Z%]/ =~ mail_header
 	mail_header = @date.strftime( mail_header )
-	mail_header = comment_mail_mime( @conf.to_mail( mail_header ) ).join( "\n " ) if /[\x80-\xff]/ =~ mail_header
+	mail_header = comment_mail_mime( @conf.to_mail( mail_header ) ).join( "\n " ) 
 
 	rmail = ''
 	begin
=== plugin/05referer.rb
==================================================================
--- plugin/05referer.rb	(revision 27329)
+++ plugin/05referer.rb	(local)
@@ -159,7 +159,7 @@
 
 def referer_add_to_diary( diary, body )
 	return unless body
-	body.each do |r|
+	body.each_line do |r|
 		count, ref = r.chomp.split( / /, 2 )
 		next unless ref
 		diary.add_referer( ref.chomp, count.to_i )
=== plugin/ja/05referer.rb
==================================================================
--- plugin/ja/05referer.rb	(revision 27329)
+++ plugin/ja/05referer.rb	(local)
@@ -31,7 +31,7 @@
 	<p>→<a href="#{h @update}?referer=volatile" target="referer">既存設定はこちら</a></p>
 	<p><textarea name="only_volatile" cols="70" rows="10">#{h @conf.only_volatile2.join( "\n" )}</textarea></p>
 	<h3 class="subtitle">#{label_referer_table}</h3>
-	#{"<p>リンク元リストのURLを、特定の文字列に変換する対応表を指定できます。1件につき、URLと表示文字列を空白で区切って指定します。正規表現が使えるので、URL中に現れた「(〜)」は、置換文字列中で「\\1」のような「\数字」で利用できます。</p>" unless @conf.mobile_agent?}
+	#{"<p>リンク元リストのURLを、特定の文字列に変換する対応表を指定できます。1件につき、URLと表示文字列を空白で区切って指定します。正規表現が使えるので、URL中に現れた「(〜)」は、置換文字列中で「\\\\1」のような「\\数字」で利用できます。</p>" unless @conf.mobile_agent?}
 	<p>→<a href="#{h @update}?referer=table" target="referer">既存設定はこちら</a></p>
 	<p><textarea name="referer_table" cols="70" rows="10">#{h @conf.referer_table2.collect{|a|a.join( " " )}.join( "\n" )}</textarea></p>
 	HTML
=== tdiary/defaultio.rb
==================================================================
--- tdiary/defaultio.rb	(revision 27329)
+++ tdiary/defaultio.rb	(local)
@@ -13,7 +13,7 @@
 		header, body = data.split( /\r?\n\r?\n/, 2 )
 		headers = {}
 		if header then
-			header.each do |l|
+			header.each_line do |l|
 				l.chomp!
 				key, val = l.scan( /([^:]*):\s*(.*)/ )[0]
 				headers[key] = val ? val.chomp : nil
=== tdiary/tdiary_style.rb
==================================================================
--- tdiary/tdiary_style.rb	(revision 27329)
+++ tdiary/tdiary_style.rb	(local)
@@ -22,7 +22,7 @@
 			if lines.size > 1 then
 				if /^<</ =~ lines[0]
 					@subtitle = lines.shift.chomp.sub( /^</, '' )
-				elsif /^[　 <]/u !~ lines[0]
+				elsif /^[ <]/u !~ lines[0]
 					@subtitle = lines.shift.chomp
 				end
 			end
@@ -190,10 +190,10 @@
 				if /^</ =~ section.body then
 					r << %Q[#{section.body}]
 				elsif section.subtitle
-					r << %Q[<p>#{section.body.collect{|l|l.chomp.sub( /^[　 ]/u, '')}.join( "</p>\n<p>" )}</p>\n]
+					r << %Q[<p>#{section.body.collect{|l|l.chomp.sub( /^[ ]/u, '')}.join( "</p>\n<p>" )}</p>\n]
 				else
 					r << %Q[<p><%= subtitle_proc( Time::at( #{date.to_i} ), nil ) %>]
-					r << %Q[#{section.body.collect{|l|l.chomp.sub( /^[　 ]/u, '' )}.join( "</p>\n<p>" )}</p>]
+					r << %Q[#{section.body.collect{|l|l.chomp.sub( /^[ ]/u, '' )}.join( "</p>\n<p>" )}</p>]
 				end
 				r << %Q[<%= section_leave_proc( Time::at( #{date.to_i} ) ) %>\n]
 				r << %Q[</div>]
@@ -211,10 +211,10 @@
 				if /^</ =~ section.body then
 					r << section.body
 				elsif section.subtitle
-					r << %Q[<P>#{section.body.collect{|l|l.chomp.sub( /^[　 ]/u, '' )}.join( "</P>\n<P>" )}</P>\n]
+					r << %Q[<P>#{section.body.collect{|l|l.chomp.sub( /^[ ]/u, '' )}.join( "</P>\n<P>" )}</P>\n]
 				else
 					r << %Q[<P><%= subtitle_proc( Time::at( #{date.to_i} ), nil ) %>]
-					r << %Q[#{section.body.collect{|l|l.chomp.sub( /^[　 ]/u, '' )}.join( "</P>\n<P>" )}</P>\n]
+					r << %Q[#{section.body.collect{|l|l.chomp.sub( /^[ ]/u, '' )}.join( "</P>\n<P>" )}</P>\n]
 				end
 				r << %Q[<%= section_leave_proc( Time::at( #{date.to_i} ) ) %>\n]
 			end
=== tdiary.rb
==================================================================
--- tdiary.rb	(revision 27329)
+++ tdiary.rb	(local)
@@ -6,10 +6,11 @@
 You can redistribute it and/or modify it under GPL2.
 =end
 
-TDIARY_VERSION = '2.3.1'
+TDIARY_VERSION = '2.3.1.20081115'
 
 $:.insert( 1, File::dirname( __FILE__ ) + '/misc/lib' )
 
+require 'compatible'
 require 'cgi'
 require 'uri'
 begin
@@ -460,6 +461,7 @@
 			load
 
 			instance_variables.each do |v|
+				v = v.to_s
 				v.sub!( /@/, '' )
 				instance_eval( <<-SRC
 					def #{v}
@@ -660,11 +662,10 @@
 				cgi_conf.untaint unless @secure
 				def_vars = ""
 				variables.each do |var| def_vars << "#{var} = nil\n" end
-				eval( def_vars )
+				extend_vars = 'variables.each do |var| eval "@#{ var} = #{var} if #{var} != nil" end'
 				Safe::safe( @secure ? 4 : 1 ) do
-					eval( cgi_conf, binding, "(TDiary::Config#cgi_conf)", 1 )
+					eval( def_vars + cgi_conf + extend_vars, binding, "(TDiary::Config#cgi_conf)", 1 )
 				end
-				variables.each do |var| eval "@#{var} = #{var} if #{var} != nil" end
 			rescue IOError, Errno::ENOENT
 			end
 		end
@@ -776,6 +777,7 @@
 			@subtitle_procs.taint
 			@section_leave_procs.taint
 			return Safe::safe( secure ? 4 : 1 ) do
+				src.force_encoding('UTF-8')
 				eval( src, binding, "(TDiary::Plugin#eval_src)", 1 )
 			end
 		end
=== update.rb
==================================================================
--- update.rb	(revision 27329)
+++ update.rb	(local)
@@ -1,11 +1,11 @@
 #!/usr/bin/env ruby
 #
-# update.rb $Revision: 1.22 $
+# update.rb
 #
-# Copyright (C) 2001-2003, TADA Tadashi <sho@spc.gr.jp>
+# Copyright (C) 2001-2008, TADA Tadashi <sho@spc.gr.jp>
 # You can redistribute it and/or modify it under GPL2.
 #
-BEGIN { $defout.binmode }
+BEGIN { $stdout.binmode }
 $KCODE = 'n'
 
 begin
@@ -55,7 +55,7 @@
 				'status' => '200 OK',
 				'type' => 'text/html',
 				'charset' => conf.mobile_encoding,
-				'Content-Length' => body.size.to_s,
+				'Content-Length' => body.bytesize.to_s,
 				'Vary' => 'User-Agent'
 			)
 		else
@@ -64,7 +64,7 @@
 				'status' => '200 OK',
 				'type' => 'text/html',
 				'charset' => conf.encoding,
-				'Content-Length' => body.size.to_s,
+				'Content-Length' => body.bytesize.to_s,
 				'Vary' => 'User-Agent'
 			)
 		end
