MODALIAS=acpi:LNXSYSTM:
     =ˆÕÔØ653Ó¾Ö �    =‹      Õ—ßo›0ÇßûWx~Ø[pBH3µ„‰�·¢A@5UÓT9@‚U‚#ã.ëþú™kÓ)YW	!í‰;óå¸�í;ŒþÆ^ZñM€ÁUì¹ ¸þà:€#„¾L-„ìØnohÊx‚ö!€¹»„öû½²Ÿ*ŒoP¢\lU‚ÓD(©H¡q¦×cÆÐóŒ¤ò
tAE‘N™f? [ÄîEEÓLC]¡‚%¤Èá·7X¹ëw:jõ2êBè+–>Ô‘'¯ˆ"ÅÍËÉª	V›ÜÐE¾“‚nÊl�n7 âÉ"š°²B«‚”wÊ†®! …XÀ¯Žµü&uHäõÓ†N@Î³õ¾·þåraBÃ'ÛLGä¸Æk5.©Ø²”®i–žG­8¢?O´¥Æ††�U	§;AYù$Eñ5aEµ#’u&	r~¨j%éK³A’g“˜!öcÛ	Û)IëOÙ]h„g¥ 6åY"èòm~[®ªÝåotÙpºÉ4 �£ÊW Ü—w%Û—‡r†ŽæïZ·¦m‡8Šä‚=Ú‡éþ‘Ÿ:VÏGcm¤Î�ª^L4 N'ÓùÀ ÖÒuÍ7 �ÝˆªÌ¼�Aê6ÕbÔVSmöyXÇ–eã|t,3v–~Có|¨,M�¼É<lF×!ö$IÃtà÷z Z³"Íø!Ï©îÕäEæ'¡Ž¦ó^d™�&s0>¿˜�O³ÞÊ¼¥�c3¼iY:§—ò«£ø¦×¶€ÚèegÍ‡îÇþµ‡CÇj)Z»�™60H`8l0«ˆéÐ1vqp%k¢yôþÏ‰�®:j£—W´¿|ÿñ|‰º“·ŽšÓ»ŽÚÿ‚_ƒÁj­z    @   ?ˆl–ßi~” ”†»Ò€nãMÜŠbÑ¿�þBG¤YÀ¶![i÷�üÿÚƒu�?Ù_ˆI|¥�+V[(ÀØ �    ?# <@LICENSE>
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements.  See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to you under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License.  You may obtain a copy of the License at:
# 
#     http://www.apache.org/licenses/LICENSE-2.0
# 
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# </@LICENSE>
#
# TODO: where are the tests?

=head1 NAME

URIDetail - test URIs using detailed URI information

=head1 SYNOPSIS

This plugin creates a new rule test type, known as "uri_detail".  These
rules apply to all URIs found in the message.

  loadplugin    Mail::SpamAssassin::Plugin::URIDetail

=head1 RULE DEFINITIONS AND PRIVILEGED SETTINGS

The format for defining a rule is as follows:

  uri_detail SYMBOLIC_TEST_NAME key1 =~ /value1/i  key2 !~ /value2/ ...

Supported keys are:

C<raw> is the raw URI prior to any cleaning
(e.g. "http://spamassassin.apache%2Eorg/").

C<type> is the tag(s) which referenced the raw_uri.  I<parsed> is a
faked type which specifies that the raw_uri was parsed from the
rendered text.

C<cleaned> is a list including the raw URI and various cleaned
versions of the raw URI (http://spamassassin.apache%2Eorg/,
https://spamassassin.apache.org/).

C<text> is the anchor text(s) (text between E<lt>aE<gt> and E<lt>/aE<gt>) that
linked to the raw URI.

C<domain> is the domain(s) found in the cleaned URIs, as trimmed to
registrar boundary by Mail::SpamAssassin::Util::RegistrarBoundaries(3).

C<host> is the full host(s) in the cleaned URIs. (Supported since SA 3.4.5)

Example rule for matching a URI where the raw URI matches "%2Ebar",
the domain "bar.com" is found, and the type is "a" (an anchor tag).

  uri_detail TEST1 raw =~ /%2Ebar/  domain =~ /^bar\.com$/  type =~ /^a$/

Example rule to look for suspicious "https" links:

  uri_detail FAKE_HTTPS text =~ /\bhttps:/  cleaned !~ /\bhttps:/

Regular expressions should be delimited by slashes.

=cut

package Mail::SpamAssassin::Plugin::URIDetail;
use Mail::SpamAssassin::Plugin;
use Mail::SpamAssassin::Logger;
use Mail::SpamAssassin::Util qw(untaint_var compile_regexp);

use strict;
use warnings;
# use bytes;
use re 'taint';

our @ISA = qw(Mail::SpamAssassin::Plugin);

# constructor
sub new {
  my $class = shift;
  my $mailsaobject = shift;

  # some boilerplate...
  $class = ref($class) || $class;
  my $self = $class->SUPER::new($mailsaobject);
  bless ($self, $class);

  $self->register_eval_rule("check_uri_detail");

  $self->set_config($mailsaobject->{conf});

  return $self;
}

sub set_config {
  my ($self, $conf) = @_;
  my @cmds;

  my $pluginobj = $self;        # allow use inside the closure below

  push (@cmds, {
    setting => 'uri_detail',
    is_priv => 1,
    code => sub {
      my ($self, $key, $value, $line) = @_;

      if ($value !~ /^(\S+)\s+(.+)$/) {
	return $Mail::SpamAss