The Underground Blog and URI hacking
Kevin Ballard
kevin at sb.org
Thu Sep 8 22:23:52 EDT 2005
The Underground Blog cannot be accessed via MouseHole, because
URI.parse() doesn't accept ___._ as a valid hostname.
Here's a patch that hacks URI to allow non-standard hosts. Applying
this allows me to access ___._ via MouseHole.
Note: I added an entry for ___._ to ::HOSTS just for kicks. After
looking at it, it seems that the entry for hoodwink.d isn't doing
anything (AFAICT ::HOSTS is only used for mounts), so adding an entry
for ___._ is useless, but I did it anyway. Or am I missing something
about ::HOSTS?
=== mouseHole
==================================================================
--- mouseHole (revision 28)
+++ mouseHole (revision 29)
@@ -1,10 +1,12 @@
#!/usr/bin/env ruby
require './lib/mouseHole'
+require './lib/uri-hack'
MOUSEHOST = ARGV[0] || "127.0.0.1"
MOUSEPORT = ARGV[1] || 37004
::HOSTS = Hash[ *%W[
hoodwink.d 65.125.236.166
+ ___._ 65.125.236.166
mouse.hole #{ MOUSEHOST }:#{ MOUSEPORT }
mh #{ MOUSEHOST }:#{ MOUSEPORT }
] ]
=== lib/uri-hack.rb
==================================================================
--- lib/uri-hack.rb (revision 28)
+++ lib/uri-hack.rb (revision 29)
@@ -0,0 +1,18 @@
+# Hacks URI to allow a host of ___._
+# Actually, it basically just hacks URI to allow any host for HTTP URLs
+# but it does it in somewhat of a roundabout way
+
+URI::HTTP.class_eval {
+ # Allow http URIs to accept a registry field
+ def self.use_registry
+ true
+ end
+
+ # If we get a nil host, set the host to the registry.
+ # This allows us to accept non-standard hosts, like ___._
+ def initialize(*args)
+ super(*args)
+ self.set_host(self.registry) if self.host.nil?
+ self.set_registry(nil)
+ end
+}
--
Kevin Ballard
kevin at sb.org
http://www.tildesoft.com
http://kevin.sb.org
-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 2378 bytes
Desc: not available
Url : http://rubyforge.org/pipermail/mousehole-scripters/attachments/20050908/6fe06e22/smime.bin
More information about the Mousehole-scripters
mailing list