• Do not register here on develop.twiki.org, login with your twiki.org account.
• Use View topic Item7848 for generic doc work for TWiki-6.1.1. Use View topic Item7851 for doc work on extensions that are not part of a release. More... Close
• Anything you create or change in standard webs (Main, TWiki, Sandbox etc) will be automatically reverted on every SVN update.
Does this site look broken?. Use the LitterTray web for test cases.

The new WebTopicCreator in 4.0.0 has some JavaScript in the input field for the page name that looks like it is trying to deal with mapping non-ASCII (ISO8859-Latin1?) characters to ASCII near-equivalents. Unfortunately, it has the side effect of removing some perfectly valid topic name characters, such as numbers. The original JavaScript looks like this (this was originally all on one line, but I formatted it on multiple lines to make it easier to follow the code):

onBlur="
var sIn = this.value; 
var sOut = ''; 
var chgUpper = true; 
for ( var i = 0; i < sIn.length; i++ ) {
  var ch = sIn.charAt( i );
  var ch2 = '';

  if((ch=='&#224;')
     ||(ch=='&#225;')
     ||(ch=='&#226;')
     ||(ch=='&#227;')
     ||(ch=='&#229;') ) {
    ch = 'a';
  }
  if( (ch=='&#232;')||(ch=='&#233;')||(ch=='&#234;') ) {
    ch = 'e';
  }
  if( ch=='&#231;') {
    ch = 'c';
  }
  if( ch=='&#241;') {
    ch = 'n';
  }
  if( (ch=='&#242;')||(ch=='&#243;')||(ch=='&#244;') ) {
    ch = 'o';
  }
  if( ch=='&#228;') {
    ch = 'a';
    ch2 = 'e';
  }
  if( ch=='&#246;') {
    ch = 'o';
    ch2 = 'e';
  }
  if( (ch=='&#249;')||(ch=='&#250;')||(ch=='&#251;') ) {
    ch = 'o';
  }
  if( ch=='&#252;') {
    ch = 'u';
    ch2 = 'e';
  }
  if( ch=='&#196;') {
    ch = 'A';
    ch2 = 'e';
  }
  if( ch=='&#214;') {
    ch = 'O';
    ch2 = 'e';
  }
  if( ch=='&#220;') {
    ch = 'U';
    ch2 = 'e';
  }
  if( ch=='&#223;') {
    ch = 's';
    ch2 = 's';
  }
  if( ((ch>='a')&&(ch<='z')) || ((ch>='A')&&(ch<='Z')) ) {
    if( chgUpper ) {
      ch = ch.toUpperCase();
      chgUpper = false;
    }
    sOut+=ch;
    if( ch2!='') {
      sOut+=ch2;
    }
  } else {
    if( ch==' ' ) {
      chgUpper = true;
    }
  }
}
this.form.topic.value=sOut;" 

I think it should be changed to something more like this:

onBlur="
var sIn = this.value; 
var sOut = ''; 
var chgUpper = true; 
for ( var i = 0; i < sIn.length; i++ ) {
  var ch = sIn.charAt( i );
  var ch2 = '';

  if((ch=='&#224;')
     ||(ch=='&#225;')
     ||(ch=='&#226;')
     ||(ch=='&#227;')
     ||(ch=='&#229;') ) {
    ch = 'a';
  }
  if( (ch=='&#232;')||(ch=='&#233;')||(ch=='&#234;') ) {
    ch = 'e';
  }
  if( ch=='&#231;') {
    ch = 'c';
  }
  if( ch=='&#241;') {
    ch = 'n';
  }
  if( (ch=='&#242;')||(ch=='&#243;')||(ch=='&#244;') ) {
    ch = 'o';
  }
  if( ch=='&#228;') {
    ch = 'a';
    ch2 = 'e';
  }
  if( ch=='&#246;') {
    ch = 'o';
    ch2 = 'e';
  }
  if( (ch=='&#249;')||(ch=='&#250;')||(ch=='&#251;') ) {
    ch = 'o';
  }
  if( ch=='&#252;') {
    ch = 'u';
    ch2 = 'e';
  }
  if( ch=='&#196;') {
    ch = 'A';
    ch2 = 'e';
  }
  if( ch=='&#214;') {
    ch = 'O';
    ch2 = 'e';
  }
  if( ch=='&#220;') {
    ch = 'U';
    ch2 = 'e';
  }
  if( ch=='&#223;') {
    ch = 's';
    ch2 = 's';
  }
  if( ((ch>='a')&&(ch<='z')) || ((ch>='A')&&(ch<='Z')) ) {
    if( chgUpper ) {
      ch = ch.toUpperCase();
      chgUpper = false;
    }
  }
  sOut+=ch;
  if( ch2!='') {
    sOut+=ch2;
  }
  if( ch==' ' ) {
    chgUpper = true;
  } else {
    chgUpper = false;
  }
}
this.form.topic.value=sOut;" 

The change is right at the end. The current code will only keep (mapped) characters within the range A-Za-z, because the

sOut+=ch;
line is controlled by that if statement. Adding the characters into the result needs to be outside of that if, as shown in the proposed correction.

I made one other small change, too. Where it checks for a space and then sets the chgUpper flag, I set it to false if the character just added was not a space. Without this change, if the user enters a page name like Meeting minutes 2006x02x06, this gets changed to MeetingMinutes2006X02x06 --- note that the "x" after "2006" got changed to upper case. With the change, it will be rendered as MeetingMinutes2006x02x06 (i.e., lower case "x" after "2006"), which I think is more likely to be what was wanted.


Thank you for this suggestion, David, much better now!

SVN 8996, tagged for 4.0.2.

-- SP

Thinking about this, as with Dakar all kinds of I18N topics will be linked pr. default, I18N-stuff should really also be allowed pr default in topics created with the creator.

(See DanishCharsÆØÅ for a "demo" - develop doesn't run a danish locale).

SVN 9321, Develop + TWiki4.

-- SP

Closed with 4.0.2 release

KJL

ItemTemplate
Summary WebTopicCreator disallows topic names containing numbers
ReportedBy TWiki:Main.DavidBright
Codebase

SVN Range Thu, 02 Feb 2006 build 8675
AppliesTo Engine
Component

Priority Normal
CurrentState Closed
WaitingFor

Checkins 8996 9321 9322
TargetRelease patch
Edit | Attach | Watch | Print version | History: r7 < r6 < r5 < r4 < r3 | Backlinks | Raw View |  Raw edit | More topic actions
Topic revision: r7 - 2006-04-02 - KennethLavrsen
 
This site is powered by the TWiki collaboration platform Powered by PerlCopyright © 2008-2024 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding TWiki? Send feedback