Changeset 1131

Show
Ignore:
Timestamp:
2008-11-04 23:47:54 (2 months ago)
Author:
MaierMan
Message:

* allow data urls
* don't scale logos up

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/chrome/content/dta/manager/metalinker.js

    r1129 r1131  
    9494                        // check for some popular bad links :p 
    9595                        if (['http', 'https', 'ftp'].indexOf(url.scheme) == -1 || url.host.indexOf('.') == -1) { 
    96                                 throw new Exception("bad link!"); 
    97                         } 
    98                         if (allowed instanceof Array && allowed.indexOf(url.scheme) == -1) { 
    99                                 throw new Exception("not allowed"); 
     96                                if (!(allowed instanceof Array)) { 
     97                                        throw new Exception("bad link!"); 
     98                                } 
     99                                if (allowed.indexOf(url.scheme) == -1) { 
     100                                                throw new Exception("not allowed"); 
     101                                        } 
    100102                        } 
    101103                        return url.spec; 
     
    254256                                        'size': size, 
    255257                                        'version': this._getSingle(file, 'version'), 
    256                                         'logo': this._checkURL(this._getSingle(file, 'logo')), 
     258                                        'logo': this._checkURL(this._getSingle(file, 'logo', ['data'])), 
    257259                                        'lang': this._getSingle(file, 'language'), 
    258260                                        'sys': this._getSingle(file, 'os'), 
     
    269271                                        'identity': this._getSingle(root, 'identity'), 
    270272                                        'description': this._getSingle(root, 'description'), 
    271                                         'logo': this._checkURL(this._getSingle(root, 'logo')), 
     273                                        'logo': this._checkURL(this._getSingle(root, 'logo', ['data'])), 
    272274                                        'license': this._getLinkRes(root, "license"), 
    273275                                        'publisher': this._getLinkRes(root, "publisher"), 
     
    347349                                let w = logo.naturalWidth; 
    348350                                let h = logo.naturalHeight; 
    349                                 let d = Math.max(w, h); 
     351                                let d = Math.max(canvas.width, w, h); 
    350352                                 
    351                                 ctx.scale(canvas.width / d, canvas.height / d); 
     353                                if (d != canvas.width) { 
     354                                        ctx.scale(canvas.width / d, canvas.height / d); 
     355                                } 
    352356                                 
    353357                                ctx.drawImage(logo, (d - w) /2, (d - h) / 2);