Skip to content

Commit

Permalink
Item13378: more fixes for unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Comment committed May 14, 2015
1 parent 3daf5fc commit fd18802
Show file tree
Hide file tree
Showing 7 changed files with 33 additions and 22 deletions.
Expand Up @@ -185,7 +185,7 @@ sub compare {
$tmpl_d = $tmpl_a unless $tmpl_d =~ /\S/;

# Start the output
my $output = '';
my $output = $tmpl_before;

# Compare the trees

Expand Down
5 changes: 3 additions & 2 deletions RCSStoreContrib/lib/Foswiki/Store/Rcs/Handler.pm
Expand Up @@ -1053,6 +1053,7 @@ sub getLease {

my $filename = $this->_controlFileName('lease');
if ( -e $filename ) {

my $t = $this->readFile($filename);
my $lease = { split( /\r?\n/, $t ) };
return $lease;
Expand All @@ -1074,10 +1075,10 @@ sub removeSpuriousLeases {
my $web = "$Foswiki::cfg{DataDir}/$this->{web}";
if ( opendir( my $W, fn2b($web) ) ) {
foreach my $f ( readdir($W) ) {
my $file = $web . b2fn($f);
my $file = $web . '/' . b2fn($f);
if ( $file =~ /^(.*)\.lease$/ ) {
if ( !-e "$1.txt,v" ) {
unlink( fn2b("$1.lease") ); # $file is tainted
unlink( fn2b("$1.lease") );
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions TablePlugin/test/unit/TablePlugin/TablePluginTests.pm
Expand Up @@ -629,7 +629,7 @@ ACTUAL
</thead>
<tbody>
<tr class="foswikiTableEven foswikiTableRowdataBgSorted0 foswikiTableRowdataBg0">
<td rowspan="1" class="foswikiTableCol0 foswikiSortedAscendingCol foswikiSortedCol foswikiFirstCol foswikiLastCol"> &nbsp; </td>
<td rowspan="1" class="foswikiTableCol0 foswikiSortedAscendingCol foswikiSortedCol foswikiFirstCol foswikiLastCol"> </td>
</tr>
<tr class="foswikiTableOdd foswikiTableRowdataBgSorted1 foswikiTableRowdataBg1">
<td rowspan="1" class="foswikiTableCol0 foswikiSortedAscendingCol foswikiSortedCol foswikiFirstCol foswikiLastCol"> -1.1 thingies </td>
Expand Down Expand Up @@ -699,7 +699,7 @@ ACTUAL
</thead>
<tbody>
<tr class="foswikiTableEven foswikiTableRowdataBgSorted0 foswikiTableRowdataBg0">
<td rowspan="1" class="foswikiTableCol0 foswikiSortedAscendingCol foswikiSortedCol foswikiFirstCol foswikiLastCol"> &nbsp; </td>
<td rowspan="1" class="foswikiTableCol0 foswikiSortedAscendingCol foswikiSortedCol foswikiFirstCol foswikiLastCol"> </td>
</tr>
<tr class="foswikiTableOdd foswikiTableRowdataBgSorted1 foswikiTableRowdataBg1">
<td rowspan="1" class="foswikiTableCol0 foswikiSortedAscendingCol foswikiSortedCol foswikiFirstCol foswikiLastCol"> -1 </td>
Expand Down
33 changes: 21 additions & 12 deletions UnitTestContrib/test/unit/HTMLValidationTests.pm
Expand Up @@ -411,27 +411,36 @@ sub verify_switchboard_function {
);
}
else {
my $warn = qr/$testcase \(\d+:\d+\) Warning:/;
for ($output) {

# Remove OK warnings
# Empty title, no easy fix and harmless
# Empty style, see Item11608
s/^$testcase \(\d+:\d+\) Warning: trimming empty <(?:h1|span|style|ins|noscript)>\n?$//gm;
s/^$testcase \(\d+:\d+\) Warning: inserting implicit <(?:ins)>\n?$//gm;

# Remove warnings about HTML5 not being covered by HTML::Tidy properly, see Item13134
s/^$testcase \(\d+:\d+\) Warning: <a> proprietary attribute "data-.*"//gm;
s/^$testcase \(\d+:\d+\) Warning: <textarea> proprietary attribute "data-.*?"//gm;
s/^$testcase \(\d+:\d+\) Warning: <input> proprietary attribute "placeholder"//gm;
s/^$testcase \(\d+:\d+\) Warning: <meta> proprietary attribute "charset"//gm;
s/^$testcase \(\d+:\d+\) Warning: <meta> lacks "content" attribute//gm;
s/^$testcase \(\d+:\d+\) Warning: <[^>]+> proprietary attribute "class"//gm;
s/^$warn trimming empty <(?:h1|span|style|ins|noscript)>\n?$//gm;
s/^$warn inserting implicit <(?:ins)>\n?$//gm;

# Remove warnings about HTML5 not being covered by
# HTML::Tidy properly, see Item13134
s/^$warn <a> proprietary attribute "data-.*$//gm;
s/^$warn <textarea> proprietary attribute "data-.*$//gm;
s/^$warn <input> proprietary attribute "placeholder".*$//gm;
s/^$warn <meta> proprietary attribute "charset".*$//gm;
s/^$warn <meta> lacks "content" attribute.*$//gm;
s/^$warn <[^>]+> proprietary attribute "class".*$//gm;

# These elements are no longer suppported in HTML5
s/^$testcase \(\d+:\d+\) Warning: <table> lacks "summary" attribute//gm;
s/^$warn <table> lacks "summary" attribute$//gm;

s/^\s*$//;
if ($Foswiki::UNICODE) {

# With unicode core, links may include unicode
# characters that *should* be url-encoded, but
# often are not (though it's not seen as an
# error by modern browsers)
s/^$warn <a> escaping malformed.*$//gm;
}
s/^\s*$//s;
}

if ( defined( $expect_table_summary_warnings{$SCRIPT_NAME} )
Expand Down
1 change: 0 additions & 1 deletion UnitTestContrib/test/unit/StoreImplementationTests.pm
Expand Up @@ -852,7 +852,6 @@ sub verify_setLease_getLease {
$meta->finish();

$this->{sut}->removeSpuriousLeases( $this->{t_web} );

$meta =
Foswiki::Meta->new( $this->{session}, $this->{t_web}, $this->{t_topic} );
$this->assert_null( $this->{sut}->getLease($meta) );
Expand Down
4 changes: 3 additions & 1 deletion WysiwygPlugin/lib/Foswiki/Plugins/WysiwygPlugin/TML2HTML.pm
Expand Up @@ -970,7 +970,9 @@ m/$startww(($Foswiki::regex{webNameRegex}\.)?$Foswiki::regex{wikiWordRegex}($Fos
$class = " class='$class'";
}

$url = Foswiki::urlEncode($url);
# SMELL: we can't Foswiki::urlEncode here, because it will change the text
# of the link and we need to keep it as written
# $url = Foswiki::urlEncode($url);
return $this->_liftOutGeneral(
"<a$class$dataWikiword href=\"$url\">$text<\/a>",
{ tag => 'NONE', protect => 0, tmltag => 0 }
Expand Down
6 changes: 3 additions & 3 deletions core/lib/Foswiki.pm
Expand Up @@ -2811,8 +2811,8 @@ RFC 1738, Dec. '94:
reserved purposes may be used unencoded within a URL.
</verbatim>
Reserved characters are $&+,/:;=?@ - these are _also_ encoded by
this method.
However this function is tuned for use with Foswiki. As such, it
encodes *all* characters except 0-9a-zA-Z-_.:~!*#/
=cut

Expand All @@ -2821,7 +2821,7 @@ sub urlEncode {

# URLs work quite happily with %-encoded utf-8 characters
$text = Encode::encode_utf8($text);
$text =~ s{([^0-9a-zA-Z-_.:~!*/])}{sprintf('%%%02x',ord($1))}ge;
$text =~ s{([^0-9a-zA-Z-_.:~!*#/])}{sprintf('%%%02x',ord($1))}ge;

return $text;
}
Expand Down

0 comments on commit fd18802

Please sign in to comment.