diff --git a/ttyverse.pl b/ttyverse.pl index c91f23e..c7b74ea 100755 --- a/ttyverse.pl +++ b/ttyverse.pl @@ -195,7 +195,6 @@ BEGIN { # exception_is_maskable=0 # Allow masking exceptions # simplestart=0 # Simple startup mode # noratelimit=0 # Ignore rate limiting -# notco=0 # Disable t.co URL expansion # === ADVANCED/TECHNICAL === # runcommand= # Command to run on startup @@ -293,7 +292,7 @@ EOF leader ssl rc norc vcheck apibase notifytype exts noreblogs synch runcommand authtype oauthkey oauthsecret tokenkey tokensecret credurl keyf readlinerepaint - simplestart exception_is_maskable oldperl notco + simplestart exception_is_maskable oldperl notify_tool_path oauthurl oauthauthurl oauthaccurl oauthbase signals_use_posix dostream eventbuf streamallreplies createrc @@ -1943,9 +1942,9 @@ for(;;) { "sorry, you can't post anonymously. use an authenticated username.\n") if ($anonymous && length($status)); die( -"sorry, status too long: reduce by @{[ &length_tco($status)-$linelength ]} chars, ". +"sorry, status too long: reduce by @{[ length($status)-$linelength ]} chars, ". "or use -autosplit={word,char,cut}.\n") - if (&length_tco($status) > $linelength && !$autosplit); + if (length($status) > $linelength && !$autosplit); ($status, $next) = &csplit($status, ($autosplit eq 'char' || $autosplit eq 'cut') ? 1 : 0) if (!length($next)); @@ -2249,7 +2248,6 @@ sub defaultmain { print C "rsga---------------\n"; $dont_use_counter = $nocounter; eval '$termrl->hook_no_counter'; - $tco_sub = sub { return &main::fastturntotco(shift); }; eval '$termrl->hook_no_tco'; if ($termrl) { print $stdout "-- DEBUG: Starting readline loop with implementation: " . $termrl->ReadLine . "\n" if ($verbose); @@ -3629,7 +3627,7 @@ EOF } # pull out entities. this works for DMs and posts. - # btw: T.CO IS WACK. + # extract URL entities from fediverse posts if (m#^/ent?(ities)? ([dDzZ]?[a-zA-Z]?[0-9]+)$#) { my $v; my $w; @@ -9998,11 +9996,10 @@ sub grabjson { return &map_mastodon_fields($my_json_ref); } -# convert t.co into actual URLs. separate from normalizejson because other +# expand shortened URLs into actual URLs. separate from normalizejson because other # things need this. modified from /entities. sub destroy_all_tco { my $hash = shift; - return $hash if ($notco); my $v; my $w; @@ -10799,43 +10796,11 @@ sub uhex { return $k; } -# for t.co -# adapted from github.com/fediverse/fediverse-text-js/blob/master/fediverse-text.js -# this is very hard to get right, and I know there are edge cases. this first -# one is designed to be quick and dirty because it needs to be fast more than -# it needs to be accurate, since T:RL:T calls it a LOT. however, it can be -# fooled, see below. -sub fastturntotco { - my $s = shift; - my $w; - # turn domain names into http urls. this should look at .com, .net, - # .etc., but things like you.suck.too probably *should* hit this - # filter. this uses the heuristic that a domain name over some limit - # is probably not actually a domain name. - ($s =~ s#\b(([a-zA-Z0-9-_]\.)+([a-zA-Z]){2,})\b#((length($w="$1")>45)?$w:"http://$w")#eg); - - # now turn all http and https URLs into t.co strings - ($s =~ s#\b(https?)://[a-zA-Z0-9-_]+[^\s]*?('|\\|\s|[\.;:,!\?]\s+|[\.;:,!\?]$|$)#\1://t.co/1234567\2#gi); - return $s; -} -# slow t.co converter. this is for future expansion. -sub turntotco { - return &fastturntotco(shift); -} - -sub ulength_tco { - my $w = shift; - return &ulength(($notco) ? $w : &turntotco($w)); -} -sub length_tco { - my $w = shift; - return length(($notco) ? $w : &turntotco($w)); -} # take a string and return up to $linelength CHARS plus the rest. -sub csplit { return &cosplit(@_, sub { return &length_tco(shift); }); } +sub csplit { return &cosplit(@_, sub { return length(shift); }); } # take a string and return up to $linelength BYTES plus the rest. -sub usplit { return &cosplit(@_, sub { return &ulength_tco(shift); }); } +sub usplit { return &cosplit(@_, sub { return &ulength(shift); }); } sub cosplit { # this is the common code for &csplit and &usplit. # this is tricky because we don't want to split up UTF-8 sequences, so