Changeset 1108

Show
Ignore:
Timestamp:
2008-10-07 16:12:00 (1 month ago)
Author:
MaierMan
Message:
  • fix _checkURL
  • do not repy on the type attr

Files:

Legend:

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

    r1105 r1108  
    4444                case 'dta': 
    4545                        return NS_DTA; 
    46           default: 
    47             return NS_METALINKER; 
    48                 break;   
    4946          } 
     47    return NS_METALINKER;                
    5048        } 
    5149};  
     
    9593                        } 
    9694                        // check for some popular bad links :p 
    97                         if (['http', 'https', 'ftp'].indexOf(url.scheme) != -1 && url.host.indexOf('.') == -1) { 
    98                                 throw new Components.Exception("bad link!"); 
     95                        if (['http', 'https', 'ftp'].indexOf(url.scheme) == -1 || url.host.indexOf('.') == -1) { 
     96                                throw new Exception("bad link!"); 
    9997                        } 
    10098                        if (allowed instanceof Array && allowed.indexOf(url.scheme) == -1) { 
    101                                 throw new Components.Exception("not allowed"); 
     99                                throw new Exception("not allowed"); 
    102100                        } 
    103101                        return url.spec; 
     
    184182                                let urlNodes = this._getNodes(file, 'ml:resources/ml:url'); 
    185183                                for each (var url in urlNodes) { 
    186                                         let type = url.getAttribute('type'); 
    187184                                        let preference = 1; 
    188185                                        let charset = doc.characterSet; 
    189                                         let usable = null; 
     186                                        if (url.hasAttributeNS(NS_DTA, 'charset')) { 
     187                                                charset = url.getAttributeNS(NS_DTA, 'charset'); 
     188                                        } 
     189 
     190                                        let uri = null; 
     191                                        try { 
     192                                                uri = this._checkURL(url.textContent.trim()); 
     193                                                if (!uri) { 
     194                                                        throw new Exception("Invalid url"); 
     195                                                }                                                        
     196                                                uri = IOService.newURI(uri, charset, null); 
     197                                        } 
     198                                        catch (ex) { 
     199                                                continue; 
     200                                        } 
    190201                                         
    191202                                        if (url.hasAttribute('preference')) { 
     
    201212                                                } 
    202213                                        } 
    203                                         if (url.hasAttributeNS(NS_DTA, 'charset')) { 
    204                                                 charset = url.getAttributeNS(NS_DTA, 'charset'); 
    205                                         } 
    206                                         if (['http', 'https', 'ftp'].indexOf(type) != -1) { 
    207                                                 url = this._checkURL(url.textContent.trim()); 
    208                                                 if (url) { 
    209                                                         urls.push(new DTA_URL(IOService.newURI(url, charset, null), preference)); 
    210                                                 } 
    211                                         } 
     214                                        urls.push(new DTA_URL(uri, preference)); 
    212215                                } 
    213216                                if (!urls.length) {