<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array"/>
  <modified type="array">
    <modified>
      <diff>@@ -1,3 +1,4 @@
+require &quot;cgi&quot;
 module Clickatell
   class API
 
@@ -14,8 +15,8 @@ module Clickatell
   
       # Returns a URL for the given parameters (a hash).
       def with_params(param_hash)
-        param_string = '?' + param_hash.map { |key, value| &quot;#{key}=#{value}&quot; }.sort.join('&amp;')
-        return URI.parse(File.join(api_service_uri, @command_name + URI.encode(param_string)))
+        param_string = '?' + param_hash.map { |key, value| &quot;#{::CGI.escape(key.to_s)}=#{::CGI.escape(value.to_s)}&quot; }.sort.join('&amp;')
+        return URI.parse(File.join(api_service_uri, @command_name + param_string))
       end
 
       protected</diff>
      <filename>lib/clickatell/api/command.rb</filename>
    </modified>
    <modified>
      <diff>@@ -24,8 +24,8 @@ module Clickatell
     end
     
     it &quot;should URL encode any special characters in parameters&quot; do
-      url = @command.with_params(:param_one =&gt; 'abc', :param_two =&gt; 'hello world')
-      url.should == URI.parse(&quot;http://api.clickatell.com/http/cmdname?param_one=abc&amp;param_two=hello%20world&quot;)
+      url = @command.with_params(:param_one =&gt; 'abc', :param_two =&gt; 'hello world &amp; goodbye cruel world &lt;grin&gt;')
+      url.should == URI.parse(&quot;http://api.clickatell.com/http/cmdname?param_one=abc&amp;param_two=hello+world+%26+goodbye+cruel+world+%3Cgrin%3E&quot;)
     end
     
     it &quot;should use a custom host when constructing command URLs if specified&quot; do
@@ -113,10 +113,10 @@ module Clickatell
     it &quot;should support sending messages to a specified number, returning the message id&quot; do
       @executor.expects(:execute).with('sendmsg', 'http', 
         :to =&gt; '4477791234567',
-        :text =&gt; 'hello world'
+        :text =&gt; 'hello world &amp; goodbye'
       ).returns(response = stub('response'))
       Response.stubs(:parse).with(response).returns('ID' =&gt; 'message_id')      
-      @api.send_message('4477791234567', 'hello world').should == 'message_id'
+      @api.send_message('4477791234567', 'hello world &amp; goodbye').should == 'message_id'
     end
     
     it &quot;should set the :from parameter and set the :req_feat to 48 when using a custom from string when sending a message&quot; do</diff>
      <filename>spec/api_spec.rb</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>8e833740212eb7eccd69c144446f70e4b54811f9</id>
    </parent>
  </parents>
  <author>
    <name>Tom Brice</name>
    <email>tomtoday@gmail.com</email>
  </author>
  <url>http://github.com/lukeredpath/clickatell/commit/a3a6b33f908690049e2e0f65ae23de9f0b32f385</url>
  <id>a3a6b33f908690049e2e0f65ae23de9f0b32f385</id>
  <committed-date>2009-06-25T03:12:09-07:00</committed-date>
  <authored-date>2009-06-24T20:45:13-07:00</authored-date>
  <message>Adjust Clickatell::API::Command#with_params to create query strings that handle special characters properly.

This fix was made to handle ampersands in text message bodies correctly.  Prior to this ampersands in the message would truncate the message

Signed-off-by: Luke Redpath &lt;luke@lukeredpath.co.uk&gt;</message>
  <tree>a009fa79d1b0c1655b249d14b1c84cd230359070</tree>
  <committer>
    <name>Luke Redpath</name>
    <email>luke@lukeredpath.co.uk</email>
  </committer>
</commit>
