mirror of
https://github.com/gnh1201/welsonjs.git
synced 2025-02-11 09:24:58 +00:00
Add support punycode (IDNA)
This commit is contained in:
parent
ed63417c06
commit
728294b7d1
15
app/assets/py/idnaencode.py
Normal file
15
app/assets/py/idnaencode.py
Normal file
|
@ -0,0 +1,15 @@
|
|||
#-*- coding: utf-8 -*-
|
||||
|
||||
import sys
|
||||
|
||||
def main(args):
|
||||
if len(args) < 2:
|
||||
print("Insufficient arguments")
|
||||
sys.exit()
|
||||
|
||||
encoded_domain = args[1].encode('idna').decode("utf-8")
|
||||
|
||||
print(encoded_domain)
|
||||
|
||||
if __name__ == "__main__":
|
||||
main(sys.argv)
|
30
lib/http.js
30
lib/http.js
|
@ -705,6 +705,34 @@ var HTTPObject = function(engine) {
|
|||
return data;
|
||||
};
|
||||
|
||||
this.getFrameURLs = function() {
|
||||
if (typeof this.responseBody !== "string") {
|
||||
return [];
|
||||
}
|
||||
|
||||
var urls = [];
|
||||
var response = this.responseBody;
|
||||
var pos = response.indexOf('<iframe ');
|
||||
|
||||
while (pos > -1) {
|
||||
var end = response.indexOf('</iframe>', pos);
|
||||
|
||||
if (response.indexOf('</iframe>', pos) < 0) {
|
||||
continue;
|
||||
}
|
||||
|
||||
var a = response.indexOf('src="', pos);
|
||||
var b = response.indexOf('"', a + 5);
|
||||
if (a > 0 && b > 0) {
|
||||
urls.push(response.substring(a + 5, b));
|
||||
}
|
||||
|
||||
pos = response.indexOf('<iframe ', pos + end);
|
||||
}
|
||||
|
||||
return urls;
|
||||
};
|
||||
|
||||
this.create();
|
||||
};
|
||||
|
||||
|
@ -720,6 +748,6 @@ exports.get = function(url, data, headers) {
|
|||
return (new HTTPObject()).setHeaders(headers).setParameters(data).setUseCache(false).get(url).responseBody;
|
||||
};
|
||||
|
||||
exports.VERSIONINFO = "HTTP Lib (http.js) version 0.7";
|
||||
exports.VERSIONINFO = "HTTP Lib (http.js) version 0.7.1";
|
||||
exports.global = global;
|
||||
exports.require = global.require;
|
||||
|
|
11
lib/punycode.js
Normal file
11
lib/punycode.js
Normal file
|
@ -0,0 +1,11 @@
|
|||
var Py3 = require("lib/python3");
|
||||
|
||||
function encode(s) {
|
||||
return Py3.execScript("app\\assets\\py\\idnaencode.py", [s]).trim();
|
||||
}
|
||||
|
||||
exports.encode = encode;
|
||||
|
||||
exports.VERSIONINFO = "Punycode Converter (punycode.js) version 0.1";
|
||||
exports.global = global;
|
||||
exports.require = global.require;
|
Loading…
Reference in New Issue
Block a user