#!/usr/bin/env ruby # # Copyright (c) 2007, Gregory Fleischer (gfleischer@gmail.com) # License: Revised BSD # # deparse confoo based files # if ARGV.length == 0 puts "usage: deconfoo.rb " exit 1 end name = ARGV[0] lines = [] File.foreach(name) {|line| lines << line } data = lines.join data.gsub!(/([^\n]{40})\\\n/) {|m| m[0,40]} if data =~ /t1\s*=\s*\"([^\"]+)\"/ t = $1 t.gsub!(/%[A-Fa-f0-9]{2}/) { |m| "%c" % m[1,2].hex } File.open("t1.html.orig", 'w') do |file| file << t end if t =~ // then puts "original t1 url most likely #{$1}" end else puts "failed to parse t1" end if data =~ /t2\s*=\s*\"([^\"]+)\"/ t = $1 t.gsub!(/%[A-Fa-f0-9]{2}/) { |m| "%c" % m[1,2].hex } File.open("t2.html.orig", 'w') do |file| file << t end if t =~ // then puts "original t2 url most likely #{$1}" end else puts "failed to parse t2" end # eof