Permalink
Browse files

Item3288: Exclamation mark not parsed when form definition topic is read

git-svn-id: http://svn.foswiki.org/trunk@7483 0b4bb1d4-4e5a-0410-9cc4-b2b747904278
  • Loading branch information...
SvenDowideit SvenDowideit
SvenDowideit authored and SvenDowideit committed May 20, 2010
1 parent 02aeebd commit dfa4135f8cda996a5009b4a83f5419fb1764c394
Showing with 44 additions and 2 deletions.
  1. +42 −1 UnitTestContrib/test/unit/FormDefTests.pm
  2. +2 −1 core/lib/Foswiki/Form.pm
@@ -45,12 +45,17 @@ sub test_allCols {
| *Name* | *Type* | *Size* | *Value* | *Tooltip* | *Attributes* |
| Select | select | 2..4 | a,b,c | Tippity | M |
| Checky Egg | checkbox | 1 | 1,2,3,4 | Blip | |
| [[FormTest][The title]] | textarea | 80x20 | some initial | Write Something | |
| %NOP%TMLDoNotLink | textarea | 80x20 | some initial | Write Something | |
| <nop>HTMLDoNotLink | textarea | 80x20 | some initial | Write Something | |
| !BangDoNotLink | textarea | 80x20 | some initial | Write Something | |
| DoLink | textarea | 80x20 | some initial | Write Something | |
FORM
$topicObject->save();
my $def =
new Foswiki::Form( $this->{session}, $this->{test_web}, 'TestForm' );
$this->assert_equals( 2, scalar @{ $def->getFields() } );
$this->assert_equals( 7, scalar @{ $def->getFields() } );
my $f = $def->getField('Select');
$this->assert_str_equals( 'select', $f->{type} );
$this->assert_str_equals( 'Select', $f->{name} );
@@ -71,6 +76,42 @@ FORM
$this->assert_str_equals( 'Blip', $f->{tooltip} );
$this->assert_str_equals( '', $f->{attributes} );
$this->assert_str_equals( '', $f->{definingTopic} );
$f = $def->getField('Thetitle');
$this->ASSERT($f);
$this->assert_str_equals( 'textarea', $f->{type} );
$this->assert_str_equals( 'Thetitle', $f->{name} );
$this->assert_str_equals( 'The title', $f->{title} );
$this->assert_str_equals( 'FormTest', $f->{definingTopic} );
#SMELL: not what I expected to see!
$f = $def->getField('NOPTMLDoNotLink');
$this->ASSERT($f);
$this->assert_str_equals( 'textarea', $f->{type} );
$this->assert_str_equals( 'NOPTMLDoNotLink', $f->{name} );
$this->assert_str_equals( '%NOP%TMLDoNotLink', $f->{title} );
$this->assert_str_equals( '', $f->{definingTopic} );
$f = $def->getField('HTMLDoNotLink');
$this->ASSERT($f);
$this->assert_str_equals( 'textarea', $f->{type} );
$this->assert_str_equals( 'HTMLDoNotLink', $f->{name} );
$this->assert_str_equals( '<nop>HTMLDoNotLink', $f->{title} );
$this->assert_str_equals( '', $f->{definingTopic} );
$f = $def->getField('BangDoNotLink');
$this->ASSERT($f);
$this->assert_str_equals( 'textarea', $f->{type} );
$this->assert_str_equals( 'BangDoNotLink', $f->{name} );
$this->assert_str_equals( '!BangDoNotLink', $f->{title} );
$this->assert_str_equals( '', $f->{definingTopic} );
$f = $def->getField('DoLink');
$this->ASSERT($f);
$this->assert_str_equals( 'textarea', $f->{type} );
$this->assert_str_equals( 'DoLink', $f->{name} );
$this->assert_str_equals( 'DoLink', $f->{title} );
$this->assert_str_equals( '', $f->{definingTopic} );
}
sub test_valsFromOtherTopic {
View
@@ -143,6 +143,7 @@ valid "name" for storing in meta-data
sub fieldTitle2FieldName {
my ($text) = @_;
return '' unless defined($text);
$text =~ s/!//g;
$text =~ s/<nop>//g; # support <nop> character in title
$text =~ s/[^A-Za-z0-9_\.]//g;
return $text;
@@ -189,7 +190,7 @@ sub _parseFormDefinition {
$vals ||= '';
$vals = $this->expandMacros($vals);
$vals =~ s/<\/?(nop|noautolink)\/?>//go;
$vals =~ s/<\/?(!|nop|noautolink)\/?>//go;
$vals =~ s/^\s+//g;
$vals =~ s/\s+$//g;

0 comments on commit dfa4135

Please sign in to comment.