aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorzotlabs <mike@macgirvin.com>2018-03-12 20:54:55 -0700
committerzotlabs <mike@macgirvin.com>2018-03-12 20:54:55 -0700
commitab1d47b36f21e5881900d9d805f4f7876f1c472f (patch)
tree5d0de385738ebb2fc332b38ff4a59f0cf4f1ca68
parent34399b8b47d9a85eb3c4095392ab994792257d88 (diff)
downloadvolse-hubzilla-ab1d47b36f21e5881900d9d805f4f7876f1c472f.tar.gz
volse-hubzilla-ab1d47b36f21e5881900d9d805f4f7876f1c472f.tar.bz2
volse-hubzilla-ab1d47b36f21e5881900d9d805f4f7876f1c472f.zip
unicode/emoji usernames. Warning: experimental feature, unstable, untested, disabled by default, use at your own risk, may not federate to other platforms and protocols. May not clone correctly. Bug reports which neglect to include detailed roubleshooting information and patches/pull requests will be ignored.
-rw-r--r--Zotlabs/Module/Follow.php2
-rw-r--r--Zotlabs/Module/New_channel.php20
-rw-r--r--include/channel.php4
-rw-r--r--include/text.php16
4 files changed, 36 insertions, 6 deletions
diff --git a/Zotlabs/Module/Follow.php b/Zotlabs/Module/Follow.php
index 146c4e564..d441f21d2 100644
--- a/Zotlabs/Module/Follow.php
+++ b/Zotlabs/Module/Follow.php
@@ -14,7 +14,7 @@ class Follow extends \Zotlabs\Web\Controller {
}
$uid = local_channel();
- $url = notags(trim($_REQUEST['url']));
+ $url = notags(trim(unpunify($_REQUEST['url'])));
$return_url = $_SESSION['return_url'];
$confirm = intval($_REQUEST['confirm']);
$interactive = (($_REQUEST['interactive']) ? intval($_REQUEST['interactive']) : 1);
diff --git a/Zotlabs/Module/New_channel.php b/Zotlabs/Module/New_channel.php
index 548f28c4f..ea9f27447 100644
--- a/Zotlabs/Module/New_channel.php
+++ b/Zotlabs/Module/New_channel.php
@@ -16,8 +16,15 @@ class New_channel extends \Zotlabs\Web\Controller {
require_once('library/urlify/URLify.php');
$result = array('error' => false, 'message' => '');
$n = trim($_REQUEST['name']);
-
- $x = strtolower(\URLify::transliterate($n));
+
+ $x = false;
+
+ if(get_config('system','unicode_usernames')) {
+ $x = punify(mb_strtolower($n));
+ }
+
+ if((! $x) || strlen($x) > 64)
+ $x = strtolower(\URLify::transliterate($n));
$test = array();
@@ -43,7 +50,14 @@ class New_channel extends \Zotlabs\Web\Controller {
$result = array('error' => false, 'message' => '');
$n = trim($_REQUEST['nick']);
- $x = strtolower(\URLify::transliterate($n));
+ $x = false;
+
+ if(get_config('system','unicode_usernames')) {
+ $x = punify(mb_strtolower($n));
+ }
+
+ if((! $x) || strlen($x) > 64)
+ $x = strtolower(\URLify::transliterate($n));
$test = array();
diff --git a/include/channel.php b/include/channel.php
index a754d3504..c94f5c657 100644
--- a/include/channel.php
+++ b/include/channel.php
@@ -1234,7 +1234,7 @@ function profile_load($nickname, $profile = '') {
);
if($z) {
$p[0]['picdate'] = $z[0]['xchan_photo_date'];
- $p[0]['reddress'] = str_replace('@','&#x40;',$z[0]['xchan_addr']);
+ $p[0]['reddress'] = str_replace('@','&#x40;',unpunify($z[0]['xchan_addr']));
}
// fetch user tags if this isn't the default profile
@@ -1255,7 +1255,7 @@ function profile_load($nickname, $profile = '') {
App::$profile = $p[0];
App::$profile_uid = $p[0]['profile_uid'];
- App::$page['title'] = App::$profile['channel_name'] . " - " . channel_reddress(App::$profile);
+ App::$page['title'] = App::$profile['channel_name'] . " - " . unpunify(channel_reddress(App::$profile));
App::$profile['permission_to_view'] = $can_view_profile;
diff --git a/include/text.php b/include/text.php
index 6675043e6..c1e064857 100644
--- a/include/text.php
+++ b/include/text.php
@@ -3318,3 +3318,19 @@ function featured_sort($a,$b) {
$s2 = substr($b,strpos($b,'id='),20);
return(strcmp($s1,$s2));
}
+
+
+function punify($s) {
+ require_once('vendor/simplepie/simplepie/idn/idna_convert.class.php');
+ $x = new idna_convert(['encoding' => 'utf8']);
+ return $x->encode($s);
+
+}
+
+function unpunify($s) {
+ require_once('vendor/simplepie/simplepie/idn/idna_convert.class.php');
+ $x = new idna_convert(['encoding' => 'utf8']);
+ return $x->decode($s);
+
+}
+