--------------ms000408060009010609030808
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit

Jacob Fugal wrote:
>>>Of course, you want to be careful when using eval, but it should cut
>>>it for the simple case...
>>
>>Is there some specialized version which does not evaluate its
>>(arbitrary) input, but just unformat a formatted string (and no more,
>>in particular refuse non-string lexemes such as arbitrary [dangerous]
>>ruby expressions)?
> 
> Unfortunately no. A possibility would be to write an encapsulating
> method using a regex to verify the input:
> 
>   def unescapeString( str )
>     raise TypeError, "Argument must be 'just a string'" unless
>       str =~ /some nasty regex/
>     eval( str )
>   end
> 
> I don't really want to deal with writing that regex, though, so I'll
> leave it as an exercise for the reader. :)

Hm, what you have to check is if the string to be eval'd represents
_exactly_ one ruby string-literal. So, native regex could be
/^"[^"]*"$/

This will work as long as your string doesn't contain (escaped) 
doublequotes - e.g. '"'.inspect =~ /^"[^"]*"$/ fails.

The general rule is to ignore one character after a backslash, or
to ignore 1-3 digits after a backslash, if the first character after a 
backslash is a digit (from 0-7)

That leads to
/^"(([^"\\])|(\\[^0-7])|(\\[0-7][0-7]?[0-7]?))*"$/

It basically says: First a quite, then either something harmless (no 
quote or backslash), or a backslash any a abitrary char, or a backslash
and one to three digits, and at the one a quote. The middle part may
occur zeor or more times.

Using that, you can even omit the eval completly. Try this:

class String
	def uninspect
		return nil unless self =~ 
/^"(([^"\\])|(\\[^0-7])|(\\[0-7][0-7]?[0-7]?))*"$/
		(gsub(/\\([^0-7])/) { $1 }).gsub(/\\([0-7][0-7]?[0-7]?)/) { 
$1.to_i(8).chr }
	end
end

It implement the trhe rules above, and for every possible
string str == str.inspect.uninspect should hold...

greetings, Florian Pflug




--------------ms000408060009010609030808
Content-Type: application/x-pkcs7-signature; name="smime.p7s"
Content-Transfer-Encoding: base64
Content-Disposition: attachment; filename="smime.p7s"
Content-Description: S/MIME Cryptographic Signature

MIAGCSqGSIb3DQEHAqCAMIACAQExCzAJBgUrDgMCGgUAMIAGCSqGSIb3DQEHAQAAoIIL4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