From 6af4090231754a5961690a1473ffd78c427e96dd Mon Sep 17 00:00:00 2001 From: Camille Barneaud Date: Thu, 31 Oct 2013 01:41:40 +0100 Subject: [PATCH] Make header field case insensitive #315: Header field name is now case insensitive --- drivers/chrome/js/headers.js | 2 +- drivers/firefox/content/js/driver.js | 2 +- drivers/php/Wappalyzer.php | 2 +- drivers/ruby/wappalyzer.rb | 2 +- share/js/wappalyzer.js | 4 ++-- 5 files changed, 6 insertions(+), 6 deletions(-) diff --git a/drivers/chrome/js/headers.js b/drivers/chrome/js/headers.js index 7c07f9db9..49cd21099 100644 --- a/drivers/chrome/js/headers.js +++ b/drivers/chrome/js/headers.js @@ -26,7 +26,7 @@ headers.forEach(function(line) { if ( line ) { - name = line.substring(0, line.indexOf(': ')); + name = line.substring(0, line.indexOf(': ')).toLowerCase(); value = line.substring(line.indexOf(': ') + 2, line.length - 1); responseHeaders[name] = value; diff --git a/drivers/firefox/content/js/driver.js b/drivers/firefox/content/js/driver.js index 509dabd5a..3e21b6786 100644 --- a/drivers/firefox/content/js/driver.js +++ b/drivers/firefox/content/js/driver.js @@ -100,7 +100,7 @@ var headers = {}; request.nsIHttpChannel.visitResponseHeaders(function(header, value) { - headers[header] = value; + headers[header.toLowerCase()] = value; }); w.analyze(progress.currentURI.host, progress.currentURI.spec, { headers: headers }); diff --git a/drivers/php/Wappalyzer.php b/drivers/php/Wappalyzer.php index 7c40fa764..b2fe9f24d 100644 --- a/drivers/php/Wappalyzer.php +++ b/drivers/php/Wappalyzer.php @@ -136,7 +136,7 @@ class Wappalyzer if ( strpos(trim($line), ': ') !== false ) { list($key, $value) = explode(': ', $line); - $result->headers[$key] = $value; + $result->headers[strtolower($key)] = $value; } } diff --git a/drivers/ruby/wappalyzer.rb b/drivers/ruby/wappalyzer.rb index d66b9a01e..01fde3180 100755 --- a/drivers/ruby/wappalyzer.rb +++ b/drivers/ruby/wappalyzer.rb @@ -18,7 +18,7 @@ class Wappalyzer uri, body, headers = URI(url), nil, {} Net::HTTP.start(uri.host, uri.port, :use_ssl => uri.scheme == 'https', :open_timeout => 5) do |http| resp = http.get(uri.request_uri) - resp.canonical_each{|k,v| headers[k] = v} + resp.each_header{|k,v| headers[k.downcase] = v} body = resp.body.encode('UTF-8', :invalid => :replace, :undef => :replace) end diff --git a/share/js/wappalyzer.js b/share/js/wappalyzer.js index 438c253cd..6f66052de 100644 --- a/share/js/wappalyzer.js +++ b/share/js/wappalyzer.js @@ -351,8 +351,8 @@ var wappalyzer = (function() { for ( header in w.apps[app].headers ) { parse(w.apps[app][type][header]).map(function(pattern) { - if ( typeof data[type][header] === 'string' && pattern.regex.test(data[type][header]) ) { - apps[app].setDetected(pattern, type, data[type][header], header); + if ( typeof data[type][header.toLowerCase()] === 'string' && pattern.regex.test(data[type][header.toLowerCase()]) ) { + apps[app].setDetected(pattern, type, data[type][header.toLowerCase()], header); } profiler.checkPoint(app, type, pattern.regex); });