This file is indexed.

/usr/share/weechat/perl/isgd.pl is in weechat-scripts 20111030-1.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
#
# Copyright (C) 2011  stfn <stfnmd@googlemail.com>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.
#

#
# Development is currently hosted at
# https://github.com/stfnm/weechat-scripts
#

use strict;
use warnings;
use CGI;

my %SCRIPT = (
	name => 'isgd',
	author => 'stfn <stfnmd@googlemail.com>',
	version => '0.2',
	license => 'GPL3',
	desc => 'Shorten URLs with is.gd on command',
);
my $TIMEOUT = 30 * 1000;
my %LOOKUP;

weechat::register($SCRIPT{"name"}, $SCRIPT{"author"}, $SCRIPT{"version"}, $SCRIPT{"license"}, $SCRIPT{"desc"}, "", "");
weechat::hook_command($SCRIPT{"name"}, $SCRIPT{"desc"},
	"[<URL> ...]\n",
	"Without any URL arguments, the last found URL in the current buffer will be shortened.\n\n" .
	"URL: URL to shorten. More than one URL may be given.",
	"", "command_cb", "");

sub command_cb
{
	my ($data, $buffer, $args) = @_;
	my @URLs;

	# If URLs were provided in command arguments, shorten them
	while ($args =~ m{(https?://\S+)}gi) {
		push(@URLs, $1);
	}
	# Otherwise search backwards in lines of current buffer
	if (@URLs == 0) {
		my $infolist = weechat::infolist_get("buffer_lines", $buffer, "");
		while (weechat::infolist_prev($infolist) == 1) {
			my $message = weechat::infolist_string($infolist, "message");
			while ($message =~ m{(https?://\S+)}gi) {
				my $url = $1;
				push(@URLs, $url) unless ($url =~ m{^https?://is\.gd/}gi);
			}
			last if (@URLs > 0);
		}
		weechat::infolist_free($infolist);
	}

	foreach (@URLs) {
		my $cmd = "wget -qO - \"http://is.gd/create.php?format=simple&url=" . CGI::escape($_) . "\"";
		$LOOKUP{$cmd} = $_;
		weechat::hook_process($cmd, $TIMEOUT, "process_cb", $buffer);
	}

	return weechat::WEECHAT_RC_OK;
}

sub process_cb
{
	my ($data, $command, $return_code, $out, $err) = @_;
	my $buffer = $data;

	if ($return_code == 0 && $out) {
		my $domain = "";
		$domain = $1 if ($LOOKUP{$command} =~  m{^https?://([^/]+)}gi);
		weechat::print($buffer, "$out ($domain)");
	}

	return weechat::WEECHAT_RC_OK;
}