Skip to content
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

Issue with parse result from vCD #2

Open
jonnyfiveiq opened this issue Oct 24, 2012 · 7 comments
Open

Issue with parse result from vCD #2

jonnyfiveiq opened this issue Oct 24, 2012 · 7 comments

Comments

@jonnyfiveiq
Copy link

HI again,

All connected, and returning the list of orgs. Next to create an org object, where it fails. Using your example code I cannot get it to work, any help much appreciated.

There is only one org called testorg at the moment.

@session.get_org_references.each do |org_ref|
@org_name = org_ref.name
puts @org_name
end
@org = @session.get_org_from_name(@org_name)

/Users//.rvm/rubies/ruby-1.9.3-p286/lib/ruby/gems/1.9.1/gems/nokogiri-1.5.5/lib/nokogiri/xml/document.rb:55:in read_memory': xmlParseCharRef: invalid xmlChar value 1 (Nokogiri::XML::SyntaxError) from /Users/~/.rvm/rubies/ruby-1.9.3-p286/lib/ruby/gems/1.9.1/gems/nokogiri-1.5.5/lib/nokogiri/xml/document.rb:55:inparse'
from /Users/
/.rvm/rubies/ruby-1.9.3-p286/lib/ruby/gems/1.9.1/gems/nokogiri-1.5.5/lib/nokogiri/xml.rb:33:in XML' from /Users/~/.rvm/rubies/ruby-1.9.3-p286/lib/ruby/gems/1.9.1/gems/nokogiri-happymapper-0.5.5/lib/happymapper.rb:261:inparse'
from /Users//.rvm/rubies/ruby-1.9.3-p286/lib/ruby/gems/1.9.1/gems/nokogiri-happymapper-0.5.5/lib/happymapper.rb:666:in parse' from /Users/~/.rvm/rubies/ruby-1.9.3-p286/lib/ruby/gems/1.9.1/gems/vcloud-0.0.1.1/lib/vcloud/parses_xml.rb:30:inparse_xml'
from /Users/
/.rvm/rubies/ruby-1.9.3-p286/lib/ruby/gems/1.9.1/gems/vcloud-0.0.1.1/lib/vcloud/rest_api.rb:88:in parse_response' from /Users/~/.rvm/rubies/ruby-1.9.3-p286/lib/ruby/gems/1.9.1/gems/vcloud-0.0.1.1/lib/vcloud/rest_api.rb:9:inrefresh'
from /Users//.rvm/rubies/ruby-1.9.3-p286/lib/ruby/gems/1.9.1/gems/vcloud-0.0.1.1/lib/vcloud/base_vcloud_entity.rb:30:in from_reference' from /Users/~/.rvm/rubies/ruby-1.9.3-p286/lib/ruby/gems/1.9.1/gems/vcloud-0.0.1.1/lib/vcloud/client.rb:76:inget_org_from_name'
from /Users/
/NetBeansProjects/vCloud Director/lib/main.rb:19:in `

'

@jonnyfiveiq
Copy link
Author

Further info... here is the XML that came back in string_or_io

����Testb Organization� ���Testb Organization�

@jonnyfiveiq
Copy link
Author

Sorry closed by mistake... still an issue.

@jonnyfiveiq
Copy link
Author

Ok managed to put a band aid round the problem it seems that the ParseOptions set to STRICT break it, by changing this to default_xml, this resolved the issue. Can you recommend how to fix this longer term via the vcloud gem rather than me changing the happymapper.rb...many thanks

#xml = Nokogiri::XML(xml, nil, nil, Nokogiri::XML::ParseOptions::STRICT) #OLD LINE
xml = Nokogiri::XML(xml, nil, nil, Nokogiri::XML::ParseOptions::DEFAULT_XML) #NEW AMENDED LINE
node = xml.root

@zrob
Copy link
Member

zrob commented Oct 24, 2012

Couple questions.

  1. What version of director are you working against? We built this against 1.5, so there may be some odditites on other versions.

  2. That xml you posted is clearly incomplete. Was that b/c of github filtering something out or is that exactly what you got, including the whitespace and 'Testb Organization' twice at the end?

@jonnyfiveiq
Copy link
Author

Thanks for responseŠ

  1. The version of vCD is 1.5.1.622844
  2. The XML was cut by GitHub, if I edited the comment it all showed up, here
    it is in full ����Testb Organization� ���Testb Organization�

From: Zach Robinson [email protected]
Reply-To: DieboldInc/vcloud-ruby
<reply+i-7827575-d083e9fe8a73fe1bdb45798ca4696be1118f114e-2084157@reply.gith
ub.com>
Date: Wednesday, 24 October 2012 15:44
To: DieboldInc/vcloud-ruby [email protected]
Cc: John Hardy [email protected]
Subject: Re: [vcloud-ruby] Issue with parse result from vCD (#2)

Couple questions.

  1. What version of director are you working against? We built this against
    1.5, so there may be some odditites on other versions.

  2. That xml you posted is clearly incomplete. Was that b/c of github
    filtering something out or is that exactly what you got, including the
    whitespace and 'Testb Organization' twice at the end?


Reply to this email directly or view it on GitHub
#2 (comment) .

@zrob
Copy link
Member

zrob commented Oct 24, 2012

looks like it has to do with the unicode chars on these lines:

     <Description>&#22;&#3;&#22;&#26;Testb Organization&#1;</Description>
     <FullName>&#3;&#22;&#26;Testb Organization&#1;</FullName>

Those chars are html escaped and need to be html unescaped, for example using CGI.unescapeHTML(xml_stuff) before being fed to nokogiri for parsing. Looking at the best way to do that in the vcloud gem (maybe a restclient option or something).

@zrob
Copy link
Member

zrob commented Oct 26, 2012

I pushed up a new branch called 'unicode' that I think will fix your issue. If you get a chance to give it a try and let me know then I'll push it into the gem if all is good.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants