Skip to content
Browse files

add update.fcgi.

  • Loading branch information...
1 parent c419604 commit ad15e479d412bd40b9e40e9d57aac7a9fda9eb07 @fdiary fdiary committed Sep 26, 2011
Showing with 46 additions and 0 deletions.
  1. +1 −0 ChangeLog
  2. +45 −0 update.fcgi
View
1 ChangeLog
@@ -1,4 +1,5 @@
2011-09-26 Kazuhiko <kazuhiko@fdiary.net>
+ * update.fcgi: initial commit.
* index.fcgi, misc/lib/fcgi_patch.rb: monkey patching FCGI::each_cgi so that we can accept both UTF-8 input and Shift_JIS input.
2011-09-14 SHIBATA Hiroshi <shibata.hiroshi@gmail.com>
View
45 update.fcgi
@@ -0,0 +1,45 @@
+#!/usr/bin/env ruby
+# -*- coding: utf-8; -*-
+#
+# index.fcgi $Revision: 1.35 $
+#
+# Copyright (C) 2004, Akinori MUSHA
+# Copyright (C) 2006, moriq
+# Copyright (C) 2011, Kazuhiko <kazuhiko@fdiary.net>
+# You can redistribute it and/or modify it under GPL2.
+#
+require 'fcgi'
+# workaround untaint LOAD_PATH for rubygems library path is always tainted.
+$:.each{|path| path.untaint if path.include?('fcgi') && path.tainted? }
+
+if FileTest::symlink?( __FILE__ ) then
+ org_path = File::dirname( File::readlink( __FILE__ ) ).untaint
+else
+ org_path = File::dirname( __FILE__ ).untaint
+end
+load "#{org_path}/misc/lib/fcgi_patch.rb"
+
+FCGI.each_cgi do |cgi|
+ begin
+ ENV.clear
+ ENV.update(cgi.env_table)
+ class << CGI; self; end.class_eval do
+ define_method(:new) {|*args| cgi }
+ end
+ dir = File::dirname( cgi.env_table["SCRIPT_FILENAME"] )
+ Dir.chdir(dir) do
+ load 'update.rb'
+ end
+ ensure
+ class << CGI
+ remove_method :new
+ end
+ end
+end
+
+# Local Variables:
+# mode: ruby
+# indent-tabs-mode: t
+# tab-width: 3
+# ruby-indent-level: 3
+# End:

0 comments on commit ad15e47

Please sign in to comment.
Something went wrong with that request. Please try again.