sanity check against rexml bugs in stock ruby 1.8.4 and ruby 1.8.6
authorgc <gc>
Sun, 3 Jun 2007 14:50:45 +0000 (14:50 +0000)
committergc <gc>
Sun, 3 Jun 2007 14:50:45 +0000 (14:50 +0000)
bin/booh

index c446737ffbee16748223723d5073a874c828606a..e93253006f205a7dd9ef2eedde496686158f42d7 100755 (executable)
--- a/bin/booh
+++ b/bin/booh
@@ -4558,9 +4558,37 @@ def create_main_window
     $main_window.show_all
 end
 
-Thread.abort_on_exception = true
 
 handle_options
+
+#- rexml sanity check (bugs in ruby 1.8.4, ruby 1.8.6)
+xmldoc = Document.new("<test/>")
+xmldoc << XMLDecl.new(XMLDecl::DEFAULT_VERSION, "UTF-8")
+content = ['61c3a927223c3e26'].pack("H*")  #- is some UTF-8 text but just to make sure my editor won't magically convert..
+xmldoc.root.add_attribute('attr', content)
+out = []
+xmldoc.write(out, 0)
+
+xmldoc = REXML::Document.new(out.join)
+sanity1 = xmldoc.root.attributes['attr']
+out = []
+xmldoc.write(out, 0)
+
+xmldoc = REXML::Document.new(out.join)
+sanity2 = xmldoc.root.attributes['attr']
+out = []
+xmldoc.write(out, 0)
+
+msg 3, "REXML sanity outcome: sanity1=#{sanity1}, sanity2=#{sanity2}"
+
+if sanity1 != sanity2
+    puts _("REXML sanity check failed (this is normal with unpatched ruby-1.8.4 or ruby-1.8.6, which ship a broken REXML). For safeness, won't proceed.")
+    exit 1
+end
+
+
+Thread.abort_on_exception = true
+
 read_config
 
 Gtk.init