Monday 22 September 2008

BBC and Flash 10

Many Cbeebies flash games don’t work on with flash 10 due to bogus flash version detection for mozilla browsers.
e.g. http://www.bbc.co.uk/wales/bobinogs/games/gamespage.shtml

The flash detection code is credited thus:

<!-- Flash Detect SSITool (Multi-clip pt1 of 2) v2.2 – do not copy, see http://intracat/ssi/ for usage -->

I can’t find any current references to SSITool any more, but looking into the java script it’s easy to see that this sample expression shows that the author wasn’t planning to cope with flash version numbers of more than one digit:

ssit_NavY.charAt(ssit_NavY.indexOf('.')-1)

A better expression would be:

(ssit_NavY.split('.')[0]).split(' ').pop()

So I installed filterproxy on my ubuntu machine, and because the edit UI seems buggy I had to edit the /etc/filterproxy.conf file by hand to add this fragment:

      'Rewrite' => {
        'filters' => [          'FLASHVER: rewrite regex /ssit_NavY\.charAt\(ssit_NavY\.indexOf\(\'\.\'\)-1\)/ as (ssit_NavY.split(\'.\')[0]).split(\' \').pop()'
        ]
      }


I also had to remove some other javascript fixups which dealt with blocking popup-windows and all kinds of stuff - I’m only trying to fix flash detection - my entire config is here

BBC should be ashamed for not having had someone run something like this on their webroots before now

find /var/www -name '*.htm*' -o -name '*.php' | while read f ; do \
  perl -i -pe "s/ssit_NavY\.charAt\(ssit_NavY\.indexOf\('\.'\)-1\)/(ssit_NavY.split('.')[0]).split(' ').pop()/g" "$f" \
done