Rev 16411 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
11931 | schaersvoo | 1 | #!/usr/bin/perl -w |
11189 | bpr | 2 | |
3 | |||
4 | use strict "vars"; |
||
5 | use strict "subs"; |
||
6 | use locale; |
||
7 | use warnings; |
||
8 | #$/ = undef; |
||
9 | |||
10 | my $warning1='is the first character of a delimiter but occurred as data'; |
||
11 | my $warning2="info: line \$"; |
||
12 | my $warning21=": character \"&\" is the first character of a delimiter but occurred as data"; |
||
16088 | bpr | 13 | my $warning3="Stray start tag div."; |
17111 | bpr | 14 | my $warning4="Self-closing tag syntax"; |
11189 | bpr | 15 | my $DIR="."; |
11502 | bpr | 16 | my $option=''; |
11189 | bpr | 17 | while ($_ = shift(@ARGV)) |
18 | { |
||
19 | last if (/^$/); |
||
11502 | bpr | 20 | if (/^--option=(.*)$/) { $option = $1} |
21 | elsif (/^--dir=(.*)$/) {$DIR = $1 } |
||
11189 | bpr | 22 | } |
23 | my @Files = GetFilesList ($DIR); |
||
24 | foreach my $File (@Files) { |
||
25 | treate($File); |
||
11502 | bpr | 26 | if($option==1){ treate2($File)}; |
11189 | bpr | 27 | } |
28 | |||
29 | sub treate { my ($file)=@_; |
||
30 | my $text=''; |
||
31 | open(IN,$file); |
||
32 | while (<IN>) { |
||
16351 | bpr | 33 | next if (/$warning1/); |
34 | next if (/$warning3/); |
||
35 | next if (/$warning2\d+$warning21/); |
||
17111 | bpr | 36 | next if (/no attribute "autocompletion"/); |
37 | next if (/no attribute "autocomplete"/); |
||
38 | next if (/validating: test.html/); |
||
39 | next if (/$warning4/); |
||
16351 | bpr | 40 | $text .= $_; |
11189 | bpr | 41 | } |
42 | close IN; |
||
43 | out($file, $text); |
||
44 | } |
||
45 | |||
11502 | bpr | 46 | sub treate2 { my ($file)=@_; |
47 | my $text=''; |
||
48 | open(IN,$file); |
||
49 | while (<IN>) { |
||
16351 | bpr | 50 | next if (/start tag was here/); |
51 | ##next if (/value of attribute "type" cannot be "search"/); |
||
52 | ##next if (/there is no attribute "results"/); |
||
53 | ## next if (/there is no attribute "placeholder"/); |
||
54 | next if (/there is no attribute "name"/); |
||
55 | ##next if (/there is no attribute "type"/); |
||
56 | next if (/Attribute "results" not allowed on element "input" at this point/); |
||
57 | next if (/Attribute “results” not allowed on element “input” at this point/); |
||
16374 | reyssat | 58 | next if (/Attribute results not allowed on element input at this point/); |
16351 | bpr | 59 | next if (/document type does not allow element "style" here/); |
60 | next if (/document type does not allow element "div" here\s*END/); ## last in the result come from the debug |
||
61 | next if (/document type does not allow element "link" here/); |
||
62 | next if (/Legacy encoding /); |
||
63 | next if (/The only allowed value for the /); |
||
64 | next if (/Cannot recover after last error. Any further errors will be ignored./); |
||
65 | next if (/Stray start tag “div”./); |
||
66 | next if (/Stray start tag "div"./); |
||
67 | next if (/attribute is unnecessary for JavaScript resources./); |
||
68 | next if (/attribute for the “style” element is not needed and should be omitted./); |
||
69 | $text .= $_; |
||
11516 | bpr | 70 | }; |
11502 | bpr | 71 | close IN; |
72 | $text =~ s/line \d+://g; |
||
73 | $text =~ s/END//g; |
||
11506 | bpr | 74 | $text =~ s/\n{2,}/\n/g; |
16352 | bpr | 75 | my $text1=""; |
76 | my @test=split("\n",$text); |
||
77 | for (my $i=0; $i < $#test; $i++) { |
||
78 | chomp $test[$i]; chomp $test[$i+1]; |
||
79 | if( !($test[$i] =~ /BEGIN/ && $test[$i+1] =~ /BEGIN/)) { |
||
80 | $text1 .= "\n" . $test[$i]; |
||
81 | } |
||
82 | } |
||
83 | $text=$text1; |
||
84 | $text=~ s/BEGIN//g; |
||
16411 | bpr | 85 | #if ($text =~ /error|info/) { } else { $text='' }; |
16352 | bpr | 86 | out($file, $text); |
11502 | bpr | 87 | } |
11189 | bpr | 88 | sub out { my ($bloc, $text) = @_; |
11867 | bpr | 89 | open (OUT, ">$bloc") || warn "peut pas créer $bloc"; |
11189 | bpr | 90 | print OUT $text; close OUT; |
91 | } |
||
92 | |||
93 | sub GetFilesList |
||
94 | { |
||
16351 | bpr | 95 | my $Path = $_[0]; |
96 | my $FileFound; |
||
97 | my @FilesList=(); |
||
11189 | bpr | 98 | |
16351 | bpr | 99 | # Lecture de la liste des fichiers |
100 | opendir (my $FhRep, $Path) |
||
101 | or die "Impossible d'ouvrir le repertoire $Path\n"; |
||
102 | my @Contenu = grep { !/^\.\.?$/ } readdir($FhRep); |
||
103 | closedir ($FhRep); |
||
11189 | bpr | 104 | |
16351 | bpr | 105 | foreach my $FileFound (@Contenu) { |
106 | # Traitement des fichiers |
||
107 | if ( -f "$Path/$FileFound") { |
||
108 | push ( @FilesList, "$Path/$FileFound" ); |
||
109 | } |
||
110 | # Traitement des repertoires |
||
111 | elsif ( -d "$Path/$FileFound") { |
||
112 | # Boucle pour lancer la recherche en mode recursif |
||
113 | push (@FilesList, GetFilesList("$Path/$FileFound") ); |
||
114 | } |
||
115 | } |
||
116 | return @FilesList; |
||
11189 | bpr | 117 | } |