Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

bugfix: update is not working when mobile mode, applyed patch for kaz…

…uhiko.
  • Loading branch information...
commit 52bea9db963bd4d69144367f92d5a1db3915a84b 1 parent 2407c13
@hsbt hsbt authored
Showing with 34 additions and 7 deletions.
  1. +24 −6 tdiary.rb
  2. +10 −1 update.rb
View
30 tdiary.rb
@@ -553,8 +553,14 @@ class TDiaryPreview < TDiaryAdmin
def initialize( cgi, rhtm, conf )
super
- @title = @conf.to_native( @cgi.params['title'][0] )
- @body = @conf.to_native( @cgi.params['body'][0] )
+ @title = @cgi.params['title'][0]
+ @body = @cgi.params['body'][0]
+ if @conf.mobile_agent? && String.method_defined?(:encode)
+ @title.force_encoding(@conf.mobile_encoding)
+ @body.force_encoding(@conf.mobile_encoding)
+ end
+ @title = @conf.to_native( @title )
+ @body = @conf.to_native( @body )
@old_date = @cgi.params['old'][0]
@hide = @cgi.params['hide'][0] == 'true' ? true : false
@@ -587,8 +593,14 @@ def eval_rhtml( prefix = '' )
#
class TDiaryUpdate < TDiaryAdmin
def initialize( cgi, rhtml, conf )
- @title = conf.to_native( cgi.params['title'][0] )
- @body = conf.to_native( cgi.params['body'][0] )
+ @title = cgi.params['title'][0]
+ @body = cgi.params['body'][0]
+ if conf.mobile_agent? && String.method_defined?(:encode)
+ @title.force_encoding(conf.mobile_encoding)
+ @body.force_encoding(conf.mobile_encoding)
+ end
+ @title = conf.to_native( @title )
+ @body = conf.to_native( @body )
@hide = cgi.params['hide'][0] == 'true' ? true : false
super
end
@@ -913,9 +925,15 @@ def initialize( cgi, rhtml, conf )
protected
def load( date )
@date = date
- @name = @conf.to_native( @cgi.params['name'][0] )
+ @name = @cgi.params['name'][0]
@mail = @cgi.params['mail'][0]
- @body = @conf.to_native( @cgi.params['body'][0] )
+ @body = @cgi.params['body'][0]
+ if @conf.mobile_agent? && String.method_defined?(:encode)
+ @name.force_encoding(conf.mobile_encoding)
+ @body.force_encoding(conf.mobile_encoding)
+ end
+ @name = @conf.to_native( @name )
+ @body = @conf.to_native( @body )
@comment = Comment::new( @name, @mail, @body )
dirty = DIRTY_NONE
View
11 update.rb
@@ -22,7 +22,16 @@
$:.unshift( org_path ) unless $:.include?( org_path )
require 'tdiary'
- @cgi = CGI.new
+ encoding_error = {}
+ cgi = CGI::new(:accept_charset => "UTF-8") do |name, value|
+ encoding_error[name] = value
+ end
+ if encoding_error.empty?
+ @cgi = cgi
+ else
+ @cgi = CGI::new(:accept_charset => 'shift_jis')
+ @cgi.params = cgi.params.dup
+ end
request = TDiary::Request.new( ENV, @cgi )
status, headers, body = TDiary::Dispatcher.update.dispatch_cgi( request, @cgi )
headers['type'] = headers.delete('Content-Type')
Please sign in to comment.
Something went wrong with that request. Please try again.