aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMax Kostikov <max@kostikov.co>2021-10-14 13:16:16 +0000
committerMario <mario@mariovavti.com>2021-10-14 13:16:16 +0000
commit99873504e4bc568281d5a978a6521edf3caf3da4 (patch)
treeeca6b491d23d803bdf3adeeeb80b01edd9069976
parent8ac529f5aec365f6e65c3539779b62cedbd39a28 (diff)
downloadvolse-hubzilla-99873504e4bc568281d5a978a6521edf3caf3da4.tar.gz
volse-hubzilla-99873504e4bc568281d5a978a6521edf3caf3da4.tar.bz2
volse-hubzilla-99873504e4bc568281d5a978a6521edf3caf3da4.zip
Support IDNA URLs embedding
-rw-r--r--Zotlabs/Module/Linkinfo.php3
-rw-r--r--view/js/main.js38
2 files changed, 15 insertions, 26 deletions
diff --git a/Zotlabs/Module/Linkinfo.php b/Zotlabs/Module/Linkinfo.php
index a05575cb6..038c739d5 100644
--- a/Zotlabs/Module/Linkinfo.php
+++ b/Zotlabs/Module/Linkinfo.php
@@ -29,6 +29,9 @@ class Linkinfo extends \Zotlabs\Web\Controller {
if((substr($url,0,1) != '/') && (substr($url,0,4) != 'http'))
$url = 'http://' . $url;
+ $x = parse_url($url);
+ if ($x)
+ $url = str_replace($x['host'], punify($x['host']), $url);
if($_GET['title'])
$title = strip_tags(trim($_GET['title']));
diff --git a/view/js/main.js b/view/js/main.js
index 476e78056..d3f4eff9a 100644
--- a/view/js/main.js
+++ b/view/js/main.js
@@ -1457,35 +1457,21 @@ function preview_post() {
}
function bin2hex(s) {
- // Converts the binary representation of data to hex
- //
- // version: 812.316
- // discuss at: http://phpjs.org/functions/bin2hex
- // + original by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
- // + bugfixed by: Onno Marsman
- // + bugfixed by: Linuxworld
- // * example 1: bin2hex('Kev');
- // * returns 1: '4b6576'
- // * example 2: bin2hex(String.fromCharCode(0x00));
- // * returns 2: '00'
- var v,i, f = 0, a = [];
- s += '';
- f = s.length;
-
- for (i = 0; i<f; i++) {
- a[i] = s.charCodeAt(i).toString(16).replace(/^([\da-f])$/,"0$1");
- }
-
- return a.join('');
+ // UTF-8 encoding to hex is supported
+ var bytes = new TextEncoder().encode(s);
+ return Array.from(
+ bytes,
+ byte => byte.toString(16).padStart(2, "0")
+ ).join("");
}
function hex2bin(hex) {
- var bytes = [], str;
-
- for(var i=0; i< hex.length-1; i+=2)
- bytes.push(parseInt(hex.substr(i, 2), 16));
-
- return String.fromCharCode.apply(String, bytes);
+ // UTF-8 decoding from hex is supported
+ var bytes = new Uint8Array(hex.length / 2);
+ for (i = 0; i !== bytes.length; i++) {
+ bytes[i] = parseInt(hex.substr(i * 2, 2), 16);
+ }
+ return new TextDecoder().decode(bytes);
}
function groupChangeMember(gid, cid, sec_token) {