Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Item13286: fixing use of NAMEFILTER
in foswikiWebTopicCreator.js
  • Loading branch information
MichaelDaum committed Mar 2, 2015
1 parent a1cf11d commit d6a10bf
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 12 deletions.
21 changes: 12 additions & 9 deletions JQueryPlugin/lib/Foswiki/Plugins/JQueryPlugin/FOSWIKI.pm
Expand Up @@ -80,15 +80,18 @@ sub init {
# add exported preferences to head
my @prefs = ();
foreach my $pref ( split( /\s*,\s*/, $prefs ) ) {
my $quote = ( $pref =~ /^NAMEFILTER$/ ) ? '/' : '"';
push @prefs,
' "'
. $pref . '": '
. $quote
. '%ENCODE{"%'
. $pref
. '%" type="quote"}%'
. $quote . '';
if ( $pref eq 'NAMEFILTER' ) {
push @prefs,
' "'
. $pref
. '": /%ENCODE{"%'
. $pref
. '%" type="quote"}%/g';
}
else {
push @prefs,
' "' . $pref . '": "%ENCODE{"%' . $pref . '%" type="quote"}%"';
}
}
my $text =
"<script type='text/javascript'>\njQuery.extend(foswiki, {\n \"preferences\": {\n"
Expand Down
9 changes: 6 additions & 3 deletions core/pub/System/JavascriptFiles/foswikiWebTopicCreator_src.js
Expand Up @@ -29,15 +29,18 @@
// always done, irrespective of whether we are non-wikiwording
// or not.
var inputName = $('input[name=topic]', $form).val(),
nameFilterRegex = foswiki.getPreference('NAMEFILTER'),
re = new RegExp(nameFilterRegex, 'g'),
re = foswiki.getPreference('NAMEFILTER'),
userAllowsNonWikiWord = true,
finalName,
feedbackHeader,
feedbackText,
error,
cleanName = foswiki.String.trimSpaces(inputName);

if (typeof(re) === 'string') {
re = new RegExp(re, "g");
}

/* Topic names of zero length are not allowed */
if (inputName.length === 0) {
$('input[type=submit]', $form).addClass('foswikiSubmitDisabled').attr('disabled', true);
Expand Down Expand Up @@ -179,4 +182,4 @@
return foswiki.webTopicCreator.canSubmit(this, true);
});
});
}(jQuery));
}(jQuery));

0 comments on commit d6a10bf

Please sign in to comment.