fcoury / octopi

A Ruby interface to GitHub API v2
http://hasmany.info/2009/4/18/ruby-interface-to-github-api
MIT License
216 stars 47 forks source link

Arguments should be escaped before being passed to the API #62

Closed jeffWelling closed 13 years ago

jeffWelling commented 13 years ago

Hi, I'm having trouble adding a label to an issue with Octopi, so far I think the problem may be in Octopi or the Github API. This is what I'm trying to run:

require 'octopi'
include Octopi
authenticated_with :login=>"jeffWelling",:token=>"..." do
  i=Issue.find( :user=>"jeffWelling", :repo=>"fake_repo", :number=>1 )
  i.add_label( "Fubar!" )
end

And I expected it to not throw an error. However....

ArgumentError: syntax error on line 93, col -1: `        ga.setAttribute('async', 'true');
        document.documentElement.firstChild.appendChild(ga);
      })();
    </script>
  </body>
</html>
'
        from /usr/lib/ruby/1.8/yaml.rb:133:in `load'
        from /usr/lib/ruby/1.8/yaml.rb:133:in `load'
        from /var/lib/gems/1.8/gems/httparty-0.7.7/lib/httparty/parser.rb:120:in `yaml'
        from /var/lib/gems/1.8/gems/httparty-0.7.7/lib/httparty/parser.rb:136:in `send'
        from /var/lib/gems/1.8/gems/httparty-0.7.7/lib/httparty/parser.rb:136:in `parse_supported_format'
        from /var/lib/gems/1.8/gems/httparty-0.7.7/lib/httparty/parser.rb:103:in `parse'
        from /var/lib/gems/1.8/gems/httparty-0.7.7/lib/httparty/parser.rb:66:in `call'
        from /var/lib/gems/1.8/gems/httparty-0.7.7/lib/httparty/request.rb:217:in `parse_response'
        from /var/lib/gems/1.8/gems/httparty-0.7.7/lib/httparty/request.rb:189:in `handle_response'
        from /var/lib/gems/1.8/gems/httparty-0.7.7/lib/httparty/request.rb:71:in `perform'
        from /var/lib/gems/1.8/gems/httparty-0.7.7/lib/httparty.rb:390:in `perform_request'
        from /var/lib/gems/1.8/gems/httparty-0.7.7/lib/httparty.rb:358:in `post'
        from /var/lib/gems/1.8/gems/octopi-0.4.2/lib/octopi/api.rb:142:in `post'
        from /var/lib/gems/1.8/gems/octopi-0.4.2/lib/octopi/api.rb:182:in `submit'
        from /var/lib/gems/1.8/gems/octopi-0.4.2/lib/octopi/api.rb:141:in `post'
        from /var/lib/gems/1.8/gems/octopi-0.4.2/lib/octopi/issue.rb:89:in `add_label'
        from /var/lib/gems/1.8/gems/octopi-0.4.2/lib/octopi/issue.rb:88:in `each'
        from /var/lib/gems/1.8/gems/octopi-0.4.2/lib/octopi/issue.rb:88:in `add_label'
        from (irb):6
        from /var/lib/gems/1.8/gems/octopi-0.4.2/lib/octopi.rb:65:in `authenticated_with'
        from (irb):4irb(main):008:0> 

Any suggestions or fixes?

radar commented 13 years ago

Hey Jeff, I'm a little busy this week with book stuff and I won't be able to attend to this until the weekend. I think the problem is that Octopi is pointing at the wrong URL, it looks like JavaScript in the output. Are you able to spend some time to debug this yourself and submit a concise bug report? It would save me a lot of time.

Thanks mate.

Ryan Bigg

On Tuesday, 10 May 2011 at 10:54 AM, jeffWelling wrote:

Hi, I'm having trouble adding a label to an issue with Octopi, so far I think the problem may be in Octopi or the Github API. This is what I'm trying to run:

require 'octopi'
include Octopi
authenticated_with :login=>"jeffWelling",:token=>"..." do
 i=Issue.find( :user=>"jeffWelling", :repo=>"fake_repo", :number=>1 )
 i.add_label( "Fubar!" )
end

And I expected it to not throw an error. However....

ArgumentError: syntax error on line 93, col -1: ` ga.setAttribute('async', 'true');
 document.documentElement.firstChild.appendChild(ga);
 })();
</script>
</body>
</html>
'
 from /usr/lib/ruby/1.8/yaml.rb:133:in `load'
 from /usr/lib/ruby/1.8/yaml.rb:133:in `load'
 from /var/lib/gems/1.8/gems/httparty-0.7.7/lib/httparty/parser.rb:120:in `yaml'
 from /var/lib/gems/1.8/gems/httparty-0.7.7/lib/httparty/parser.rb:136:in `send'
 from /var/lib/gems/1.8/gems/httparty-0.7.7/lib/httparty/parser.rb:136:in `parse_supported_format'
 from /var/lib/gems/1.8/gems/httparty-0.7.7/lib/httparty/parser.rb:103:in `parse'
 from /var/lib/gems/1.8/gems/httparty-0.7.7/lib/httparty/parser.rb:66:in `call'
 from /var/lib/gems/1.8/gems/httparty-0.7.7/lib/httparty/request.rb:217:in `parse_response'
 from /var/lib/gems/1.8/gems/httparty-0.7.7/lib/httparty/request.rb:189:in `handle_response'
 from /var/lib/gems/1.8/gems/httparty-0.7.7/lib/httparty/request.rb:71:in `perform'
 from /var/lib/gems/1.8/gems/httparty-0.7.7/lib/httparty.rb:390:in `perform_request'
 from /var/lib/gems/1.8/gems/httparty-0.7.7/lib/httparty.rb:358:in `post'
 from /var/lib/gems/1.8/gems/octopi-0.4.2/lib/octopi/api.rb:142:in `post'
 from /var/lib/gems/1.8/gems/octopi-0.4.2/lib/octopi/api.rb:182:in `submit'
 from /var/lib/gems/1.8/gems/octopi-0.4.2/lib/octopi/api.rb:141:in `post'
 from /var/lib/gems/1.8/gems/octopi-0.4.2/lib/octopi/issue.rb:89:in `add_label'
 from /var/lib/gems/1.8/gems/octopi-0.4.2/lib/octopi/issue.rb:88:in `each'
 from /var/lib/gems/1.8/gems/octopi-0.4.2/lib/octopi/issue.rb:88:in `add_label'
 from (irb):6
 from /var/lib/gems/1.8/gems/octopi-0.4.2/lib/octopi.rb:65:in `authenticated_with'
 from (irb):4irb(main):008:0> 

Any suggestions or fixes?

Reply to this email directly or view it on GitHub: https://github.com/fcoury/octopi/issues/62

jeffWelling commented 13 years ago

Hmm, OK I'll poke and prod and see what I can make of it. Thanks for the heads up.

jeffWelling commented 13 years ago

I just found out that removing the exclamation mark from the label allows me to successfully add a label, so the problem appears to be with escaping certain characters.

jeffWelling commented 13 years ago

So I just tested out the Github Issues 2.0 interface to see how it responds to labels with '!' in them, and it silently drops them. You can type in the label and click add, but nothing happens. When you add a label without the '!' it is added to the labels list. I'm not sure what the best way for Octopi to handle this would be, throwing an error may even be the reasonable thing to do, so I'm going to close the issue for the time being.