Skip to content

Don't unmarshal classes that don't include XMLRPC::Marshal #36

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Aug 1, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions lib/xmlrpc/parser.rb
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ def self.struct(hash)
begin
mod = Module
klass.split("::").each {|const| mod = mod.const_get(const.strip)}
return hash unless mod.included_modules.include?(XMLRPC::Marshallable)

obj = mod.allocate

Expand Down
3 changes: 3 additions & 0 deletions test/data/marshallable.expected
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
---
- true
- ___class___: Gem::Requirement
17 changes: 17 additions & 0 deletions test/data/marshallable.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?xml version="1.0" ?>
<methodResponse>
<params>
<param>
<value>
<struct>
<member>
<name>___class___</name>
<value>
<string>Gem::Requirement</string>
</value>
</member>
</struct>
</value>
</param>
</params>
</methodResponse>
7 changes: 7 additions & 0 deletions test/test_parser.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,10 @@ def setup
@datetime_xml = File.read(datafile('datetime_iso8601.xml'))
@datetime_expected = XMLRPC::DateTime.new(2004, 11, 5, 1, 15, 23)

@marshallable_xml, @marshallable_expected = load_data('marshallable')

@fault_doc = File.read(datafile('fault.xml'))
@marshallable = File.read(datafile('marshallable.xml'))
end

# test parseMethodResponse --------------------------------------------------
Expand All @@ -50,6 +53,10 @@ def test_dateTime
assert_equal(@datetime_expected, @p.parseMethodResponse(@datetime_xml)[1])
end

def test_marshallable
assert_equal(@marshallable_expected, @p.parseMethodResponse(@marshallable))
end

# test parseMethodCall ------------------------------------------------------

def test_parseMethodCall
Expand Down