-<% %>
+<%require 'IPAddr' %>
<h1>Results</h1>
<% if @election.shortdesc %>
<% next unless voter.voted? %>
<tr>
<td><%= voter.ipaddress %></td>
- <td><%= `host #{voter.ipaddress}`.sub(/^.*pointer (.*)\.$/, '\1') %></td>
+ <td><% begin %>
+ <%= `host #{IPAddr.new(voter.ipaddress).to_s}`.sub(/^.*pointer (.*)\.$/, '\1') %>
+
+ <% rescue ArgumentError => err %>
+ <%= voter.ipaddress %>
+ <% end %>
+ </td>
<td><%= voter.vote.votestring %></td>
</tr>
<% end %>