Add support punycode (IDNA)

This commit is contained in:
Namhyeon Go 2022-05-17 18:29:39 +09:00
parent ed63417c06
commit 728294b7d1
3 changed files with 55 additions and 1 deletions

View 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)

View File

@ -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
View 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;