Rubyに複数の脆弱性

Rubyに複数の脆弱性が発見されました。最新バージョンへのアップグレードを推奨します。

ということで、EC2で使ってるRubyをruby 1.8.7 (2008-08-08 patchlevel 71) [i686-linux]にアップデートしました。

よろしくお願いします。

posted by Png genki on Fri 8 Aug 2008 at 16:28 with 1 comment

Redmineで2203年の予定を立てようとしたところ、エラーが出たので原因を調べていました。 どうやら、Railsのdistance_of_time_in_wordsでエラーが出ているようです。

   1  def distance_of_time_in_words(
   2      from_time, to_time = 0, include_seconds = false)
   3    from_time = from_time.to_time if
   4      from_time.respond_to?(:to_time)
   5    to_time = to_time.to_time if
   6      to_time.respond_to?(:to_time)
   7    distance_in_minutes =
   8      (((to_time - from_time).abs)/60).round
   9    distance_in_seconds =
  10      ((to_time - from_time).abs).round

8行目あたりの減算でエラーが出ているようです。 実際、以下のような減算をしようとするとエラーが出ます。

   1  Time.now - Date.parse("Mon, 01 Aug 2203").to_time
   2  #=> RangeError: time - 7371010800.000000 out of Time range

ということで、あまりにも長い時間である場合には、 以下のような例外処理で対処するようにしました。

   1  module ActionView
   2    module Helpers
   3      module DateHelper
   4        def distance_of_time_in_words_with_limit(
   5          from_time, to_time = 0, include_seconds = false
   6        )
   7          distance_of_time_in_words_without_limit(
   8            from_time, to_time, include_seconds)
   9        rescue
  10          'a long time'
  11        end
  12        alias_method_chain :distance_of_time_in_words, :limit
  13      end
  14    end
  15  end

これで23世紀の予定も思いのままです。

posted by Png genki on Fri 8 Aug 2008 at 07:10
Contents
Ruby-1.8.7 p71にアップデート
23世紀の予定を立てる方法
Comments
瀧内元気: MacOS版は以下にあります * [genki/ViMouse](https://githu... '23-1
dsjf: https://gist.github.com/6bf1bf2c3cbb5eb6e7a7 これ... '13-1
瀧内元気: おお、チェックしてみます。thx! '11-12
overisland: Reeder for iPhone もこの UI を実装していますね。 '11-12
瀧内元気: その情報は見たのですが、以下のサイトによると、現在はまた必要になってるっぽいんですよね。 ... '11-12
Services from s21g
twpro(ツイプロ)
Twitterプロフィールを快適検索
地価2009
土地の値段を調べてみよう
MyRestaurant
自分だけのレストラン手帳
Formula
ブログに数式を埋め込める数式コミュニティ