Skip to content

Commit

Permalink
Item14256: implemented {LegacyFormfieldNames} flag
Browse files Browse the repository at this point in the history
... to prevent data loss when upgrading content from 1.x to 2.x
  • Loading branch information
MichaelDaum committed Dec 19, 2016
1 parent ec987f2 commit 47238cf
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
8 changes: 8 additions & 0 deletions core/lib/Foswiki.spec
Original file line number Diff line number Diff line change
Expand Up @@ -1482,6 +1482,14 @@ $Foswiki::cfg{Store}{filePermission} = 0644;
# Settings that control the available form fields types. Extensions may extend
# the set of available types.

# **BOOLEAN LABEL="Enable Legacy Formfield Naming" EXPERT**
# Enable legacy naming scheme for formfield names. Starting with Foswiki-2.0 formfield names are
# allowed to contain unicode characters. Before, formfield names have been normalized
# by stripping these off. If you are upgrading Foswiki from an engine previous to 2.x
# and your DataForm definitions do contain unicode characters then
# you might strongly consider enabling this flag in order to prevent data loss.
$Foswiki::cfg{LegacyFormfieldNames} = $FALSE;

# **PERL LABEL="Form Types"**
# This setting is automatically updated by configure to list all the installed
# FormField types. If you install an extension that adds new Form Field types,
Expand Down
9 changes: 7 additions & 2 deletions core/lib/Foswiki/Form.pm
Original file line number Diff line number Diff line change
Expand Up @@ -215,8 +215,13 @@ sub fieldTitle2FieldName {
my ($text) = @_;
return '' unless defined($text);
$text =~ s/!//g;
$text =~ s/<nop>//g; # support <nop> character in title
$text =~ s/[^\w\.]//g;
$text =~ s/<nop>//g; # support <nop> character in title
if ( $Foswiki::cfg{LegacyFormfieldNames} ) {
$text =~ s/[^A-Za-z0-9_\.]//g;
}
else {
$text =~ s/[^\w\.]//g;
}
return $text;
}

Expand Down

0 comments on commit 47238cf

Please sign in to comment.