Ticket #4810: 0001-Bug-4810-Weird-screen-sizes-reported-by-Panopticlick.patch

File 0001-Bug-4810-Weird-screen-sizes-reported-by-Panopticlick.patch, 2.9 KB (added by erikd, 8 years ago)

Patch to fix this bug

  • src/chrome/content/jshooks.js

    From 08777b218ae34d5d2849b6c72a7c361b00bf575e Mon Sep 17 00:00:00 2001
    From: Erik de Castro Lopo <erikd@mega-nerd.com>
    Date: Mon, 2 Jan 2012 13:25:46 +1100
    Subject: [PATCH] Bug 4810: Weird screen sizes reported by Panopticlick
    
    TorButton was reporting screen sizes to the server based on the current
    window size. Since actual screen sizes are more generic than window
    sizes, TorButton should report actual screen size instead, filtering
    for any really odd screen sizes.
    ---
     src/chrome/content/jshooks.js  |   13 +++++++++++--
     src/chrome/content/jshooks4.js |   13 +++++++++++--
     2 files changed, 22 insertions(+), 4 deletions(-)
    
    diff --git a/src/chrome/content/jshooks.js b/src/chrome/content/jshooks.js
    index aff355b..d7e99ac 100644
    a b window.__HookObjects = function() { 
    116116
    117117          var scr = new Object();
    118118          var origScr = window.screen;
    119           scr.__defineGetter__("height", function() { return window.innerHeight; });
    120           scr.__defineGetter__("width", function() { return window.innerWidth; });
     119
     120          var reportWidth = origScr.width;
     121          var reportHeight = origScr.height;
     122
     123          // Restrict the reported width/height to more common values.
     124          if (reportWidth > 1600) { reportWidth = 1600; }
     125          if (reportHeight > 1200) { reportHeight = 1200; }
     126          if (reportWidth == 1280 && reportHeight < 800) { reportHeight = 800; }
     127
     128          scr.__defineGetter__("height", function() { return reportHeight; });
     129          scr.__defineGetter__("width", function() { return reportWidth; });
    121130
    122131          scr.__defineGetter__("availTop", function() { return 0;});
    123132          scr.__defineGetter__("availLeft", function() { return 0;});
  • src/chrome/content/jshooks4.js

    diff --git a/src/chrome/content/jshooks4.js b/src/chrome/content/jshooks4.js
    index 655a04d..d33563f 100644
    a b window.__HookObjects = function() { 
    4040
    4141          var scr = new Object();
    4242          var origScr = window.screen;
    43           scr.__defineGetter__("height", function() { return window.innerHeight; });
    44           scr.__defineGetter__("width", function() { return window.innerWidth; });
     43
     44          var reportWidth = origScr.width;
     45          var reportHeight = origScr.height;
     46
     47          // Restrict the reported width/height to more common values.
     48          if (reportWidth > 1600) { reportWidth = 1600; }
     49          if (reportHeight > 1200) { reportHeight = 1200; }
     50          if (reportWidth == 1280 && reportHeight < 800) { reportHeight = 800; }
     51
     52          scr.__defineGetter__("height", function() { return reportHeight; });
     53          scr.__defineGetter__("width", function() { return reportWidth; });
    4554
    4655          scr.__defineGetter__("availTop", function() { return 0;});
    4756          scr.__defineGetter__("availLeft", function() { return 0;});