mirror of
				https://github.com/ruby/ruby.git
				synced 2022-11-09 12:17:21 -05:00 
			
		
		
		
	* ext/psych/lib/psych/visitors/to_ruby.rb: Fix cyclic references of
objects. Thanks to CvX for reporting the bug and a test case. * test/psych/test_object.rb: test for cyclic object references. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32194 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
		
							parent
							
								
									7c5fdec05d
								
							
						
					
					
						commit
						40508ede73
					
				
					 3 changed files with 24 additions and 1 deletions
				
			
		| 
						 | 
				
			
			@ -1,3 +1,9 @@
 | 
			
		|||
Wed Jun 22 03:20:52 2011  Aaron Patterson <aaron@tenderlovemaking.com>
 | 
			
		||||
 | 
			
		||||
	* ext/psych/lib/psych/visitors/to_ruby.rb: Fix cyclic references of
 | 
			
		||||
	  objects.  Thanks to CvX for reporting the bug and a test case.
 | 
			
		||||
	* test/psych/test_object.rb: test for cyclic object references.
 | 
			
		||||
 | 
			
		||||
Wed Jun 22 02:39:54 2011  Hiroshi Nakamura  <nahi@ruby-lang.org>
 | 
			
		||||
 | 
			
		||||
	* lib/net/http.rb (Net::HTTP.post_form): Do not ignore query part of
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -182,7 +182,6 @@ module Psych
 | 
			
		|||
        when /^!ruby\/object:?(.*)?$/
 | 
			
		||||
          name = $1 || 'Object'
 | 
			
		||||
          obj = revive((resolve_class(name) || Object), o)
 | 
			
		||||
          @st[o.anchor] = obj if o.anchor
 | 
			
		||||
          obj
 | 
			
		||||
 | 
			
		||||
        when /^!map:(.*)$/, /^!ruby\/hash:(.*)$/
 | 
			
		||||
| 
						 | 
				
			
			@ -233,6 +232,7 @@ module Psych
 | 
			
		|||
 | 
			
		||||
      def revive klass, node
 | 
			
		||||
        s = klass.allocate
 | 
			
		||||
        @st[node.anchor] = s if node.anchor
 | 
			
		||||
        h = Hash[*node.children.map { |c| accept c }]
 | 
			
		||||
        init_with(s, h, node)
 | 
			
		||||
      end
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -11,6 +11,14 @@ module Psych
 | 
			
		|||
    end
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  class Foo
 | 
			
		||||
    attr_accessor :parent
 | 
			
		||||
 | 
			
		||||
    def initialize parent
 | 
			
		||||
      @parent = parent
 | 
			
		||||
    end
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  class TestObject < TestCase
 | 
			
		||||
    def test_dump_with_tag
 | 
			
		||||
      tag = Tagged.new
 | 
			
		||||
| 
						 | 
				
			
			@ -23,5 +31,14 @@ module Psych
 | 
			
		|||
      assert_equal tag.baz, tag2.baz
 | 
			
		||||
      assert_instance_of(Tagged, tag2)
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
    def test_cyclic_references
 | 
			
		||||
      foo = Foo.new(nil)
 | 
			
		||||
      foo.parent = foo
 | 
			
		||||
      loaded = Psych.load Psych.dump foo
 | 
			
		||||
 | 
			
		||||
      assert_instance_of(Foo, loaded)
 | 
			
		||||
      assert_equal loaded, loaded.parent
 | 
			
		||||
    end
 | 
			
		||||
  end
 | 
			
		||||
end
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue