The Artima Developer Community
Sponsored Link

Ruby Buzz Forum
Getting RuBlog Working

0 replies on 1 page.

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 0 replies on 1 page
Eric Stewart

Posts: 72
Nickname: estewart
Registered: Dec, 2003

Eric Stewart is software developer from Austin, Texas.
Getting RuBlog Working Posted: Dec 4, 2003 9:51 PM
Reply to this message Reply

This post originated from an RSS feed registered with Ruby Buzz by Eric Stewart.
Original Post: Getting RuBlog Working
Feed Title: Ponderings On Ruby
Feed URL: http://blog.eric-stewart.com/category/programming-ruby.rss
Feed Description: This is the Ruby related section of Eric Stewart's weblog. These entries will be the commentary of a long time Java/C++ programmer that started exploring Ruby in 2003.
Latest Ruby Buzz Posts
Latest Ruby Buzz Posts by Eric Stewart
Latest Posts From Ponderings On Ruby

Advertisement
When I recently decided to give RuBlog a shot, I needed to install Ruby on my web server. I rushed out and downloaded Ruby 1.8.0 and installed it without a hitch, installed RDoc, and then attempted to get RuBlog up and running.

With a few minor changes to a custom rublog.cgi script, my new empty blog came up like a charm. I added a simple rdoc entry, and then a plain text entry, and they worked great!

But when I attempted to click on a specific Link, or a category, or the Syndicate link, up came the apache error message. A review of the logs pointed out that I Can’t modify frozen string. Ok, fine. A quick check of the code turned up this problem code:

  # Work out the request path, and make it local to out datadir. Ignore it
  # if it contains any '..' sequences

  def determine_request_path
    request_path = ""
    path = @environment['PATH_INFO']
    if path && path !~ /\.\./
      path.slice!(0) if path[0] == ?/
      request_path = path unless path.empty?
    end
    @is_rss = request_path.sub!(/index.rss$/, '') || @parameters.has_key?('rss')

    @path = request_path
  end

The error occurred when the code attempted to slice the path, since it was apparently frozen when fetched from the environment. The problem was fixed by changing the if block to:

    if path && path !~ /\.\./
      mutable_path = path.dup
                        mutable_path.slice!(0) if mutable_path[0] == ?/
                        request_path = mutable_path unless mutable_path.empty?
    end

For complete Ruby newbies like myself, the dup operation was necessary because it creates a new object with the same data, not state. If I had used path.clone instead of path.dup the frozen state would have been carried over.

Since Ruby 1.8.0 was released in August and the last RuBlog release 3f8 came out in March, I am not too shocked by all this.


Update: It turns out, the latest cvs versions of everything in the RubLog distribution work just fine with Ruby 1.8.0, so problem was already solved. It gave me a chance to hack a little ruby though!

Read: Getting RuBlog Working

Topic: Russian-Language Ruby Resource Previous Topic   Next Topic Topic: A Lode of Ruby Links

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use