Permalink
Browse files

Item14256: implemented {LegacyFormfieldNames} flag

... 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 47238cf68eef3af218d0b99c02895aafcd45626b
Showing with 15 additions and 2 deletions.
  1. +8 −0 core/lib/Foswiki.spec
  2. +7 −2 core/lib/Foswiki/Form.pm
View
@@ -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,
View
@@ -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;
}

0 comments on commit 47238cf

Please sign in to comment.