Subversion Repositories wimsdev

Rev

Rev 11513 | Rev 11748 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | RSS feed

  1. #!/usr/bin/perl -w
  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";
  13. my $DIR=".";
  14. my $option='';
  15. while ($_ = shift(@ARGV))
  16. {
  17.   last if (/^$/);
  18.   if (/^--option=(.*)$/)  { $option = $1}
  19.   elsif  (/^--dir=(.*)$/)   {$DIR = $1 }
  20. }
  21. my @Files = GetFilesList ($DIR);
  22. foreach my $File  (@Files) {
  23.         treate($File);
  24.         if($option==1){ treate2($File)};
  25. }
  26.  
  27. sub treate { my ($file)=@_;
  28.   my $text='';
  29.   open(IN,$file);
  30.   while (<IN>) {
  31.    next if (/$warning1/);
  32.    next if (/$warning2\d+$warning21/);
  33.    next if (/data-dropdown/); #is not a member of a group specified for any attribute (html5)
  34.    next if (/no attribute \"data/); #html5
  35.    next if (/aria-label/);  #html5
  36.    next if (/nav/);  #html5
  37.    next if (/no attribute "autocompletion"/);
  38.    next if (/no attribute "autocomplete"/);
  39.    next if (/validating: test.html/);
  40.    $text .= $_;
  41.   }
  42.   close IN;
  43.   out($file, $text);
  44. }
  45.  
  46. sub treate2 { my ($file)=@_;
  47.   my $text='';
  48.   open(IN,$file);
  49.   while (<IN>) {
  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 (/document type does not allow element "style" here/);
  57.    next if (/document type does not allow element "div" here\s*END/); ## last in the result come from the debug
  58.    next if (/document type does not allow element "link" here/);
  59.    $text .= $_;
  60.   };
  61.   close IN;
  62.   $text =~ s/line \d+://g;
  63.   $text =~ s/END//g;
  64.   $text =~ s/\n{2,}/\n/g;
  65.   if ($text =~ /error|info/) {  } else { $text='' };
  66.   out($file, $text);
  67. }
  68.  
  69. sub out { my ($bloc, $text) = @_;
  70.   open  (OUT, ">$bloc") || warn "peut pas créer $bloc";
  71.   print OUT $text; close OUT;
  72.   system (`rm $bloc`) if(!$text);
  73. }
  74.  
  75. sub GetFilesList
  76. {
  77.         my $Path = $_[0];
  78.         my $FileFound;
  79.         my @FilesList=();
  80.  
  81.         # Lecture de la liste des fichiers
  82.         opendir (my $FhRep, $Path)
  83.                 or die "Impossible d'ouvrir le repertoire $Path\n";
  84.         my @Contenu = grep { !/^\.\.?$/ } readdir($FhRep);
  85.         closedir ($FhRep);
  86.  
  87.         foreach my $FileFound (@Contenu) {
  88.                 # Traitement des fichiers
  89.                 if ( -f "$Path/$FileFound") {
  90.                         push ( @FilesList, "$Path/$FileFound" );
  91.                 }
  92.                 # Traitement des repertoires
  93.                 elsif ( -d "$Path/$FileFound") {
  94.                         # Boucle pour lancer la recherche en mode recursif
  95.                         push (@FilesList, GetFilesList("$Path/$FileFound") );
  96.                 }
  97.         }
  98.         return @FilesList;
  99. }
  100.