Menu

#6 write_string in worksheet.rb modifies outside string

open
nobody
None
5
2006-11-14
2006-11-14
No

write_string in worksheet.rb modifies a string passed in through
worksheet.write.

The problem appear when upgrading from 0.3.4 to 0.3.5

I submitted a patch that fixes this problem,

https://sourceforge.net/tracker/index.php?
func=detail&aid=1596062&group_id=60975&atid=495784

Discussion

  • Karl Zilles

    Karl Zilles - 2007-01-11

    Logged In: YES
    user_id=612409
    Originator: NO

    I just got bitten by this bug too. Your patch looks like it should fix it.

     
  • Karl Zilles

    Karl Zilles - 2007-01-11

    Logged In: YES
    user_id=612409
    Originator: NO

    Here is a work around you can add to your code until the gem gets updated.
    (uncomment the puts to make sure it's working)

    class Worksheet
    alias_method :write_string_old, :write_string
    def write_string(row, col, str, format)
    # puts "Fixed!"
    write_string_old(row, col, str.clone, format)
    end
    end

     
  • Karl Zilles

    Karl Zilles - 2007-01-18

    Logged In: YES
    user_id=612409
    Originator: NO

    Crap. I needed dup and not clone since clone copies the "frozen" state of the string.

    class Worksheet
    alias_method :write_string_old, :write_string
    def write_string(row, col, str, format)
    # puts "Fixed!"
    write_string_old(row, col, str.dup, format)
    end
    end

     

Log in to post a comment.

MongoDB Logo MongoDB