From: Szabolcs Szasz Date: 2002-10-20T22:47:07+09:00 Subject: Strange String bug (around type.to_s from mod_ruby)? This is a multi-part message in MIME format. ------=_NextPart_000_00B2_01C2784F.EC675660 Content-Type: text/plain; charset="iso-8859-2" Content-Transfer-Encoding: 7bit (See attached files please.) 'eruby bug.rhtml' gives:
"Sub"
"b"
"Base"
"se"

Fine. Now, from the browser (thru mod_ruby):

"#::Sub"
"Module 0lx4048974c>::Sub"
"Base"
"se"

If in bug.rhtml you don't require bug.rb but paste it in (see 
comments in the code), then both printouts will break:

"#::Sub"
"Module 0lx4048974c>::Sub"
"#::Base"
"Module 0lx4048974c>::Base"

Also, if you play with the changes commented in bug.rb, you
can trigger/mask the error at will.

Furthermore, in the slightly different live code, even when the 
output looks good (OK, I'm not familiar with mod_ruby so I have 
no idea what that '#::' is supposed represents in the "Sub" class 
name, that alone is, well, sort of strange, but well...), so even 
when there is no "Module ..." in the output, e.g. File.mkpath(y)
(where y is the broken string) would create directory path, which 
DOES have that ghost "Module ..." thing in there!...

Kind of scary...

Seems like either I do something miserable, or there may be
a buffer overrun (if I had to place my bet... ;) ) somewhere.
(Posslibly a mod_ruby problem, so I sent this to the mod-ruby 
people already.)

Cheers,
Sab

(Apache/1.3.26 (Unix) Debian GNU/Linux mod_ruby/1.0.0 Ruby/1.6.7 
-- and I _did_ restart it a few times...)

------=_NextPart_000_00B2_01C2784F.EC675660
Content-Type: application/octet-stream;
	name="bug.rb"
Content-Transfer-Encoding: quoted-printable
Content-Disposition: attachment;
	filename="bug.rb"

class Base=0A=
	def initialize=0A=
		x =3D type.to_s		# Change this to some other string=0A=
		p x			# (e.g. to the value of type.to_s)=0A=
					# and it will start working...=0A=
					=0A=
		y =3D x[2..-1]		# Change this to 1..-1 and it will =0A=
		p y			# also work...=0A=
	end=0A=
end=0A=

------=_NextPart_000_00B2_01C2784F.EC675660
Content-Type: application/octet-stream;
	name="bug.rhtml"
Content-Transfer-Encoding: quoted-printable
Content-Disposition: attachment;
	filename="bug.rhtml"

=0A=
<%=0A=
=3Dbegin=0A=
class Base=0A=
	def initialize=0A=
		x =3D type.to_s=0A=
		p x=0A=
		y =3D x[2..-1]=0A=
		p y=0A=
	end=0A=
end=0A=
=3Dend=0A=
require 'bug.rb'=0A=
=0A=
class Sub < Base=0A=
end=0A=
=0A=
bad  =3D Sub.new=0A=
good =3D Base.new	# Becomes bad if bug.rb is pasted into this file=0A=
		# instead of being require-d... (See above.)=0A=
%>=0A=

------=_NextPart_000_00B2_01C2784F.EC675660--