diff options
author | sebdelsol <seb.morin@gmail.com> | 2015-03-11 00:44:13 +0100 |
---|---|---|
committer | sebdelsol <seb.morin@gmail.com> | 2015-03-11 00:44:13 +0100 |
commit | 879348c7244fb512b3ddd67f0c313baef82ea854 (patch) | |
tree | aab7aa9b44558c32f477f0de8780fba2598acb7d /module/plugins/hoster | |
parent | [BasePlugin][SimpleHoster] Improve checkDownload rules (diff) | |
download | pyload-879348c7244fb512b3ddd67f0c313baef82ea854.tar.xz |
[zippyshare] bug correction #1246
Handle funky introspection like :
```javascript
test = {
test: function(x, y) {
document.getElementById(x).href = y;
}
test.test('dlbutton', "http:\\ZippyshareIsFullOfTrickster.com");
```
Diffstat (limited to 'module/plugins/hoster')
-rw-r--r-- | module/plugins/hoster/ZippyshareCom.py | 33 |
1 files changed, 18 insertions, 15 deletions
diff --git a/module/plugins/hoster/ZippyshareCom.py b/module/plugins/hoster/ZippyshareCom.py index f2c99de7b..d9d1db1be 100644 --- a/module/plugins/hoster/ZippyshareCom.py +++ b/module/plugins/hoster/ZippyshareCom.py @@ -11,7 +11,7 @@ from module.plugins.internal.SimpleHoster import SimpleHoster, create_getInfo class ZippyshareCom(SimpleHoster): __name__ = "ZippyshareCom" __type__ = "hoster" - __version__ = "0.75" + __version__ = "0.76" __pattern__ = r'http://www\d{0,2}\.zippyshare\.com/v(/|iew\.jsp.*key=)(?P<KEY>[\w^_]+)' @@ -55,32 +55,35 @@ class ZippyshareCom(SimpleHoster): def get_link(self): # get all the scripts inside the html body soup = BeautifulSoup(self.html) - scripts = (s.getText() for s in soup.body.findAll('script', type='text/javascript')) + scripts = (s.getText().strip() for s in soup.body.findAll('script', type='text/javascript')) # meant to be populated with the initialization of all the DOM elements found in the scripts initScripts = set() def replElementById(element): - id = element.group(1) - attr = element.group(4) #: attr might be None - - varName = '%s_%s' % (re.sub(r'\W', '', id), attr) - initValues = filter(None, [elt.get(attr, None) for elt in soup.findAll(id=id)]) - initValue = '"%s"' % initValues[-1] if initValues else 'null' - - initScripts.add('var %s = %s;' % (varName, initValue)) + id = element.group(1) # id might be either 'x' (a real id) or x (a variable) + attr = element.group(4) # attr might be None + + varName = re.sub(r'-', '', 'GVAR[%s+"_%s"]' %(id, attr)) + + realid = id.strip('"\'') + if id != realid: #id is not a variable, so look for realid.attr in the html + initValues = filter(None, [elt.get(attr, None) for elt in soup.findAll(id=realid)]) + initValue = '"%s"' % initValues[-1] if initValues else 'null' + initScripts.add('%s = %s;' % (varName, initValue)) + return varName # handle all getElementById - reVar = r'document.getElementById\([\'"](.+)[\'"]\)(\.)?(getAttribute\([\'"])?(\w+)?([\'"]\))?' - scripts = [re.sub(reVar, replElementById, script) for script in scripts] + reVar = r'document.getElementById\(([\'"\w-]+)\)(\.)?(getAttribute\([\'"])?(\w+)?([\'"]\))?' + scripts = [re.sub(reVar, replElementById, script) for script in scripts if script] # add try/catch in JS to handle deliberate errors - scripts = ["\n".join(("try{", script, "} catch(err){}")) for script in scripts if script.strip()] + scripts = ['\n'.join(('try{', script, '} catch(err){}')) for script in scripts] # get the file's url by evaluating all the scripts - scripts = "\n".join(list(initScripts) + scripts + ['dlbutton_href']) - return self.js.eval(scripts) + scripts = ['var GVAR = {}'] + list(initScripts) + scripts + ['GVAR["dlbutton_href"]'] + return self.js.eval('\n'.join(scripts)) getInfo = create_getInfo(ZippyshareCom) |