Merge pull request #373 from gadcam/master

Make header field case insensitive
main
Elbert Alias 11 years ago
commit 8352615daa

@ -26,7 +26,7 @@
headers.forEach(function(line) { headers.forEach(function(line) {
if ( 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); value = line.substring(line.indexOf(': ') + 2, line.length - 1);
responseHeaders[name] = value; responseHeaders[name] = value;

@ -100,7 +100,7 @@
var headers = {}; var headers = {};
request.nsIHttpChannel.visitResponseHeaders(function(header, value) { request.nsIHttpChannel.visitResponseHeaders(function(header, value) {
headers[header] = value; headers[header.toLowerCase()] = value;
}); });
w.analyze(progress.currentURI.host, progress.currentURI.spec, { headers: headers }); w.analyze(progress.currentURI.host, progress.currentURI.spec, { headers: headers });

@ -136,7 +136,7 @@ class Wappalyzer
if ( strpos(trim($line), ': ') !== false ) { if ( strpos(trim($line), ': ') !== false ) {
list($key, $value) = explode(': ', $line); list($key, $value) = explode(': ', $line);
$result->headers[$key] = $value; $result->headers[strtolower($key)] = $value;
} }
} }

@ -18,7 +18,7 @@ class Wappalyzer
uri, body, headers = URI(url), nil, {} uri, body, headers = URI(url), nil, {}
Net::HTTP.start(uri.host, uri.port, :use_ssl => uri.scheme == 'https', :open_timeout => 5) do |http| Net::HTTP.start(uri.host, uri.port, :use_ssl => uri.scheme == 'https', :open_timeout => 5) do |http|
resp = http.get(uri.request_uri) 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) body = resp.body.encode('UTF-8', :invalid => :replace, :undef => :replace)
end end

@ -351,8 +351,8 @@ var wappalyzer = (function() {
for ( header in w.apps[app].headers ) { for ( header in w.apps[app].headers ) {
parse(w.apps[app][type][header]).map(function(pattern) { parse(w.apps[app][type][header]).map(function(pattern) {
if ( typeof data[type][header] === 'string' && pattern.regex.test(data[type][header]) ) { if ( typeof data[type][header.toLowerCase()] === 'string' && pattern.regex.test(data[type][header.toLowerCase()]) ) {
apps[app].setDetected(pattern, type, data[type][header], header); apps[app].setDetected(pattern, type, data[type][header.toLowerCase()], header);
} }
profiler.checkPoint(app, type, pattern.regex); profiler.checkPoint(app, type, pattern.regex);
}); });