Text-Minify-XS

 view release on metacpan or  search on metacpan

README.md  view on Meta::CPAN


## Malformed UTF-8

Malformed UTF-8 characters may be be mangled or omitted from the
output.  In extreme cases it may throw an exception in order to avoid
memory overflows. You should ensure that the input string is properly
encoded as UTF-8.

## Byte Order Marks

The Byte Order Mark (BOM) at the beginning of a file will not be removed. That is because the minifier does not know
this is the beginning of a file or not.

# SECURITY CONSIDERATIONS

Passing malformed UTF-8 characters may throw an exception, which in some cases could lead to a denial of service if
untrusted input is passed to ["minify\_utf8"](#minify_utf8).  See ["KNOWN ISSUES"](#known-issues).

# SUPPORT

Only the latest version of this module will be supported.

lib/Text/Minify/XS.pm  view on Meta::CPAN

=encoding UTF-8

=head1 NAME

Text::Minify::XS - Remove indentation and trailing whitespace from multi-line text

=head1 VERSION

version v0.7.7

=for stopwords BOM minify minifier

=head1 SYNOPSIS

  use Text::Minify::XS qw/ minify /;

  my $out = minify( $in );

=head1 DESCRIPTION

This is a simple and fast text minifier that quickly removes extra

lib/Text/Minify/XS.pm  view on Meta::CPAN


=head2 Malformed UTF-8

Malformed UTF-8 characters may be be mangled or omitted from the
output.  In extreme cases it may throw an exception in order to avoid
memory overflows. You should ensure that the input string is properly
encoded as UTF-8.

=head2 Byte Order Marks

The Byte Order Mark (BOM) at the beginning of a file will not be removed. That is because the minifier does not know
this is the beginning of a file or not.

=head1 SECURITY CONSIDERATIONS

Passing malformed UTF-8 characters may throw an exception, which in some cases could lead to a denial of service if
untrusted input is passed to L</minify_utf8>.  See L</KNOWN ISSUES>.

=head1 SUPPORT

Only the latest version of this module will be supported.

ppport.h  view on Meta::CPAN

BmPREVIOUS|5.003007||Viu
BmRARE|5.003007||Viu
BmUSEFUL|5.003007||Viu
BOL|5.003007||Viu
BOL_t8|5.035004||Viu
BOL_t8_p8|5.033003||Viu
BOL_t8_pb|5.033003||Viu
BOL_tb|5.035004||Viu
BOL_tb_p8|5.033003||Viu
BOL_tb_pb|5.033003||Viu
BOM_UTF8|5.025005|5.003007|p
BOM_UTF8_FIRST_BYTE|5.019004||Viu
BOM_UTF8_TAIL|5.019004||Viu
boolSV|5.004000|5.003007|p
boot_core_builtin|5.035007||Viu
boot_core_mro|5.009005||Viu
boot_core_PerlIO|5.007002||Viu
boot_core_UNIVERSAL|5.003007||Viu
BOUND|5.003007||Viu
BOUNDA|5.013009||Viu
BOUNDA_t8|5.035004||Viu
BOUNDA_t8_p8|5.033003||Viu
BOUNDA_t8_pb|5.033003||Viu

ppport.h  view on Meta::CPAN

#ifndef isUTF8_CHAR
#  define isUTF8_CHAR(s, e)              (                                            \
    (e) <= (s) || ! is_utf8_string(s, UTF8_SAFE_SKIP(s, e))                     \
    ? 0                                                                         \
    : UTF8SKIP(s))
#endif

#endif

#if 'A' == 65
#ifndef BOM_UTF8
#  define BOM_UTF8                       "\xEF\xBB\xBF"
#endif

#ifndef REPLACEMENT_CHARACTER_UTF8
#  define REPLACEMENT_CHARACTER_UTF8     "\xEF\xBF\xBD"
#endif

#elif '^' == 95
#ifndef BOM_UTF8
#  define BOM_UTF8                       "\xDD\x73\x66\x73"
#endif

#ifndef REPLACEMENT_CHARACTER_UTF8
#  define REPLACEMENT_CHARACTER_UTF8     "\xDD\x73\x73\x71"
#endif

#elif '^' == 176
#ifndef BOM_UTF8
#  define BOM_UTF8                       "\xDD\x72\x65\x72"
#endif

#ifndef REPLACEMENT_CHARACTER_UTF8
#  define REPLACEMENT_CHARACTER_UTF8     "\xDD\x72\x72\x70"
#endif

#else
#  error Unknown character set
#endif

t/02-minify_utf8.t  view on Meta::CPAN

is minify_utf8("\n\n  simple\r\n test\n\r") => "simple\ntest\n";

is minify_utf8("simple  \n") => "simple\n";

is minify_utf8("simple  \r") => "simple\n";

is minify_utf8("simple  \nstuff  ") => "simple\nstuff";

is minify_utf8("\r\n\r\n\t0\r\n\t\t1\r\n") => "0\n1\n";

my $BOM = chr(0xfeff);

is minify_utf8( $BOM . "simple" ) => $BOM . "simple", "ignore BOM";

done_testing;



( run in 0.540 second using v1.01-cache-2.11-cpan-131fc08a04b )