<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array"/>
  <modified type="array">
    <modified>
      <diff>@@ -136,6 +136,9 @@ class Contacts
       cookies = parse_cookies(resp.response['set-cookie'], cookies)
       forward = resp.response['Location']
       forward ||= (data =~ /&lt;meta.*?url='([^']+)'/ ? CGI.unescapeHTML($1) : nil)
+	if (not forward.nil?) &amp;&amp; URI.parse(forward).host.nil?
+		forward = url.scheme.to_s + &quot;://&quot; + url.host.to_s + forward
+	end
       return data, resp, cookies, forward
     end
     
@@ -151,6 +154,9 @@ class Contacts
       data = uncompress(resp, data)
       cookies = parse_cookies(resp.response['set-cookie'], cookies)
       forward = resp.response['Location']
+	  if (not forward.nil?) &amp;&amp; URI.parse(forward).host.nil?
+		forward = url.scheme.to_s + &quot;://&quot; + url.host.to_s + forward
+	  end
       return data, resp, cookies, forward
     end
     </diff>
      <filename>lib/contacts/base.rb</filename>
    </modified>
    <modified>
      <diff>@@ -3,6 +3,7 @@ class Contacts
     URL                 = &quot;http://login.live.com/login.srf?id=2&quot;
     OLD_CONTACT_LIST_URL = &quot;http://%s/cgi-bin/addresses&quot;
     NEW_CONTACT_LIST_URL = &quot;http://%s/mail/GetContacts.aspx&quot;
+    NEWEST_CONTACT_LIST_URL = &quot;http://%s/mail/options.aspx?subsection=26&quot;
     COMPOSE_URL         = &quot;http://%s/cgi-bin/compose?&quot;
     PROTOCOL_ERROR      = &quot;Hotmail has changed its protocols, please upgrade this library first. If that does not work, report this error at http://rubyforge.org/forum/?group_id=2693&quot;
     PWDPAD = &quot;IfYouAreReadingThisYouHaveTooMuchFreeTime&quot;
@@ -60,10 +61,32 @@ class Contacts
       end
 =end
       
-      data, resp, cookies, forward, old_url = get(&quot;http://mail.live.com/mail&quot;, cookies)
-      data, resp, cookies, forward, old_url = get(forward, cookies)
-      
-      @domain = URI.parse(forward).host
+      data, resp, cookies, forward = get(&quot;http://mail.live.com/mail&quot;, cookies)
+      until forward.nil?
+        data, resp, cookies, forward, old_url = get(forward, cookies, old_url) + [forward]
+      end
+
+    # click on 'Contiune' if presented with the Hotmail Listened page
+    #  look for the Submit button with a &quot;TakeMeToInbox&quot; name (this should work for other languages)
+    if (not old_url.grep(/MessageAtLogin.aspx/).first.nil?)
+		
+      viewState = data.split(/&gt;\s*?&lt;/).grep(/__VIEWSTATE/).first[/value=\&quot;.+?\&quot;/][7..-2]
+      eventValidation = data.split(/&gt;\s*?&lt;/).grep(/__EVENTVALIDATION/).first[/value=\&quot;.+?\&quot;/][7..-2]
+      continueValue = data.split(/&gt;\s*?&lt;/).grep(/TakeMeToInbox/).first[/value=\&quot;.+?\&quot;/][7..-2]
+
+      # post back to the same url 
+      postdata = &quot;%s=%s&amp;%s=%s&amp;%s=%s&quot; % [
+            &quot;__VIEWSTATE&quot;, CGI.escape(viewState),
+            &quot;__EVENTVALIDATION&quot;, CGI.escape(eventValidation),
+            CGI.escape(&quot;TakeMeToInbox&quot;), CGI.escape(continueValue)
+        ]
+        data, resp, cookies, forward = post( old_url, postdata, cookies, old_url )
+        until forward.nil?
+          data, resp, cookies, forward, old_url = get(forward, cookies, old_url) + [forward]
+        end
+      end
+            
+      @domain = URI.parse(old_url).host
       @cookies = cookies
     rescue AuthenticationError =&gt; m
       if @attempt == 1
@@ -73,10 +96,51 @@ class Contacts
       end
     end
     
+    def contacts(options = {})
+      return @contacts if @contacts
+      if connected?
+        url = URI.parse(contact_list_url)
+        data, resp, cookies, forward = get( contact_list_url, @cookies )
+        
+        if resp.code_type != Net::HTTPOK
+          raise ConnectionError, self.class.const_get(:PROTOCOL_ERROR)
+        end
+
+        # we have to click on the Export Contacts button to get the csv:
+        # Search the content for __VIEWSTATE or __EVENTVALIDATION
+        viewState = data.split(/&gt;\s*?&lt;/).grep(/__VIEWSTATE/).first[/value=\&quot;.+?\&quot;/][7..-2]
+        eventValidation = data.split(/&gt;\s*?&lt;/).grep(/__EVENTVALIDATION/).first[/value=\&quot;.+?\&quot;/][7..-2]
+        exportValue = data.split(/&gt;\s*?&lt;/).grep(/ctl02\$ExportButton/).first[/value=\&quot;.+?\&quot;/][7..-2]
+        mt = cookies.split(&quot;; &quot;).grep(/mt=/).first[3..-1]
+        
+        # post back to the same url 
+        postdata = &quot;%s=%s&amp;%s=%s&amp;%s=%s&amp;%s=%s&quot; % [
+          &quot;__VIEWSTATE&quot;, CGI.escape(viewState),
+          &quot;__EVENTVALIDATION&quot;, CGI.escape(eventValidation),
+          CGI.escape(&quot;ctl02$ExportButton&quot;), CGI.escape(exportValue),
+          &quot;mt&quot;, CGI.escape( mt )
+        ]
+	
+        url = URI.parse(contact_list_url)
+        http = open_http(url)
+        resp, data = http.post(&quot;#{url.path}?#{url.query}&quot;, postdata,
+          &quot;User-Agent&quot; =&gt; &quot;Mozilla/5.0 (Macintosh; U; Intel Mac OS X; en-US; rv:1.8.1) Gecko/20061010 Firefox/2.0&quot;,
+          &quot;Accept-Encoding&quot; =&gt; &quot;gzip&quot;,
+          &quot;Cookie&quot; =&gt; cookies,
+          &quot;Referer&quot; =&gt; contact_list_url,
+          &quot;Content-Type&quot; =&gt; 'application/x-www-form-urlencoded'
+        )
+
+        data = uncompress(resp, data)
+        parse(data, options)
+      end
+    end
+
+
   private
     
     def contact_list_url
-      NEW_CONTACT_LIST_URL % @domain
+      NEWEST_CONTACT_LIST_URL % @domain
     end
     
     def follow_email(data, id, contacts_slot)
@@ -100,7 +164,7 @@ class Contacts
 
     def parse(data, options={})
       data = data.split(&quot;\r\n&quot;)
-      data = CSV.parse(data.join(&quot;\r\n&quot;).gsub('&quot;', ''), ';')
+      data = CSV.parse(data.join(&quot;\r\n&quot;).gsub('&quot;', '').gsub(';', ','), ';')
       col_names = data.shift
 
       @contacts = data.delete_if{|person|person[0].nil?}.map do |person|
@@ -109,7 +173,6 @@ class Contacts
         [[person[1], person[2], person[3]].delete_if{|i|i.empty?}.join(&quot; &quot;), person[idx - 1]] unless person[idx - 1].nil?
       end.compact 
     end
-    
   end
 
   TYPES[:hotmail] = Hotmail</diff>
      <filename>lib/contacts/hotmail.rb</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>ccde414ebef57beccae1e265308eda5d8626140c</id>
    </parent>
  </parents>
  <author>
    <name>Lucas Carlson</name>
    <email>lucas@rufy.com</email>
  </author>
  <url>http://github.com/cardmagic/contacts/commit/3b293afe7aca45d62e7c78723ee1f8fc6e81fdfd</url>
  <id>3b293afe7aca45d62e7c78723ee1f8fc6e81fdfd</id>
  <committed-date>2009-01-08T12:27:35-08:00</committed-date>
  <authored-date>2009-01-08T12:27:35-08:00</authored-date>
  <message>Adding patch to fix Hotmail, thanks Graeme Rouse!</message>
  <tree>53bfc5bd0e00554d9c967de29a71d051043c2778</tree>
  <committer>
    <name>Lucas Carlson</name>
    <email>lucas@rufy.com</email>
  </committer>
</commit>
