<commit_before>#!/usr/bin/perl
#
# mySociety/Web.pm:
# CGI-like class which we can extend.
#
# Copyright (c) 2005 UK Citizens Online Democracy. All rights reserved.
# Email: <EMAIL>; WWW: http://www.mysociety.org/
#
# $Id: Web.pm,v 1.16 2007-05-02 10:31:42 matthew Exp $
#

package mySociety::Web;

use strict;

use HTML::Entities;

use Carp;
use CGI qw(-nosticky);
my $have_cgi_fast = 0;
eval {
    use CGI::Fast;
    $have_cgi_fast = 1;
};

use HTML::Entities;
use HTTP::Date qw();

use fields qw(q scratch);
@mySociety::Web::ISA = qw(Exporter); # for the Import* methods

BEGIN {
    use Exporter ();
    our @ISA = qw(Exporter);
    our @EXPORT_OK = qw(ent NewURL);
}
our @EXPORT_OK;

sub ent ($) {
    my $s = shift;
    return encode_entities($s, '<>&"');
}

=item new [QUERY]

Construct a new mySociety::Web object, optionally from an existing QUERY. Uses
CGI::Fast if available, or CGI otherwise.

=cut
sub new ($;$) {
    my ($class, $q) = @_;
    if (!defined($q)) {
        $q = $have_cgi_fast ? new CGI::Fast() : new CGI();
        return undef if (!defined($q)); # reproduce CGI::Fast behaviour
    }
    $q->autoEscape(1);
    my $self = fields::new('mySociety::Web');
    $self->{q} = $q;
    $self->{scratch} = { };
    return bless($self, $class);
}
<commit_msg>Attempt #2. Seems to be working fine on FMS, MaPit, Gaze, and WTT queue.cgi, so commit same change for cvswww, WTT rest, PB various, DaDem, EvEl, NeWs, Ratty, match.cgi, petitions.<commit_after>#!/usr/bin/perl
#
# mySociety/Web.pm:
# CGI-like class which we can extend.
#
# Copyright (c) 2005 UK Citizens Online Democracy. All rights reserved.
# Email: <EMAIL>; WWW: http://www.mysociety.org/
#
# $Id: Web.pm,v 1.17 2008-02-04 22:50:30 matthew Exp $
#

package mySociety::Web;

use strict;

use HTML::Entities;

use Carp;
use CGI qw(-nosticky);
my $have_cgi_fast = 0;
eval {
    use mySociety::CGIFast;
    $have_cgi_fast = 1;
};

use HTML::Entities;
use HTTP::Date qw();

use fields qw(q scratch);
@mySociety::Web::ISA = qw(Exporter); # for the Import* methods

BEGIN {
    use Exporter ();
    our @ISA = qw(Exporter);
    our @EXPORT_OK = qw(ent NewURL);
}
our @EXPORT_OK;

sub ent ($) {
    my $s = shift;
    return encode_entities($s, '<>&"');
}

=item new [QUERY]

Construct a new mySociety::Web object, optionally from an existing QUERY. Uses
mySociety::CGIFast if available, or CGI otherwise.

=cut
sub new ($;$) {
    my ($class, $q) = @_;
    if (!defined($q)) {
        $q = $have_cgi_fast ? new mySociety::CGIFast() : new CGI();
        return undef if (!defined($q)); # reproduce mySociety::CGIFast behaviour
    }
    $q->autoEscape(1);
    my $self = fields::new('mySociety::Web');
    $self->{q} = $q;
    $self->{scratch} = { };
    return bless($self, $class);
}

{'fraction_non_alphanumeric': 0.16986599058312205, 'fraction_numerical': 0.01774719304599783, 'mean_word_length': 3.557755775577558, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 3, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1305834', 'n_tokens_mistral': 1133, 'n_tokens_neox': 1047, 'n_words': 295}