File: clean-and-pre_282503.patch

package info (click to toggle)
libhtml-clean-perl 1.4-1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 388 kB
  • sloc: perl: 444; makefile: 2
file content (46 lines) | stat: -rw-r--r-- 1,464 bytes parent folder | download | duplicates (2)
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
Description: Added documentation (and a warning) explaining why HTML::Clean does
 not properly handle preformatted areas
Origin: vendor
Bug: https://rt.cpan.org/NoAuth/Bug.html?id=6772
Bug-Debian: https://bugs.debian.org/282503
Author: Gunnar Wolf <gwolf@debian.org>
Reviewed-by: gregor herrmann <gregoa@debian.org>
Last-Update: 2019-12-22

--- a/lib/HTML/Clean.pm
+++ b/lib/HTML/Clean.pm
@@ -365,6 +365,16 @@ The following options are recognized:
 
 =back
 
+Please note that if your HTML includes preformatted regions (this means, if
+it includes <pre>...</pre>, we do not suggest removing whitespace, as it will
+alter the rendered defaults.
+
+HTML::Clean will print out a warning if it finds a preformatted region and is
+requested to strip whitespace. In order to prevent this, specify that you don't
+want to strip whitespace - i.e.
+
+  $h->strip( {whitespace => 0} );
+
 =cut
 
 use vars qw/
@@ -425,6 +435,17 @@ sub strip {
   }
 
   if ($do_whitespace) {
+    if ($$h =~ /<pre/i) {
+      warn << 'EOF'
+Warning: Stripping whitespace will affect preformatted region\'s layout
+You have a <pre> region in your HTML, which depends on the whitespace not
+being modified. You requested to strip the whitespace - The rendered results
+will be affected.
+
+Hint: Use $h->strip({whitespace => 0}); instead.
+EOF
+    }
+
     $$h =~ s,[\r\n]+,\n,sg; # Carriage/LF -> LF
     $$h =~ s,\s+\n,\n,sg;   # empty line
     $$h =~ s,\n\s+<,\n<,sg; # space before tag