• 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.

Item6807: Configure: invalid html, restricted input control width

Item Form Data

AppliesTo: Component: Priority: CurrentState: WaitingFor: TargetRelease ReleasedIn
Engine Configure Urgent Closed   patch 5.1.1

Edit Form Data

Reported By:
Applies To:
Current State:
Waiting For:
Target Release:
Released In:


Configure is generating bad html - and not doing what's intended. Instead, it arbitrarily restricts field widths to 55 characters.

In TWiki::Configure::Type, the following logic exists (similar logic is in other configure types):

sub prompt {
    my( $this, $id, $opts, $value ) = @_;
    my $size = '55%';
    if( $opts =~ /\b(\d+)\b/ ) {
        $size = $1;
        # These numbers are somewhat arbitrary..
        if( $size > 25 ) {
            $size = '55%';
    return CGI::textfield( -name => $id, -size=>$size, -default=>$value );

Clearly, the intent is that for field sizes greater than 25 characters, the box should be 55% of the screen width. I don't particularly agree with this, since I have fields that really need to be greater than ... well, let's see:

The html spec says that size is the initial width of the control, for text fields in integer characters. (http://www.w3.org/TR/html4/interact/forms.html#adef-size-INPUT) It says nothing about percentage of screen width. (A length can be specified in % of screen width, which is probably where the confusion arises.)

And, in fact when I've turned on debuggers in several web browsers, we see that they parse size="55%" as size="55". So the net effect is that no field can be displayed as wider than 55 characters, regardless of the the screen width or .spec file width.

This is bad. There are a few complicated solutions (css, tables, among them) to try to get to the original intent, but the simplest thing to do is:

    my $size = '55';       # Delete the %
    if( $opts =~ /\b(\d+)\b/ ) {
        $size = $1;

        # Delete the bogus conversion to %

Note that this code snippet is replicated in Configure, including Configure/Type.pm and Configure/Types/PASSWORD.pm, but many other classes are derived from these...

-- TWiki:Main/TimotheLitt - 2011-09-13

On reflection, an alternate (ultra conservative) fix could be:

sub prompt {
    my $size = '55';
    if( $opts =~ /\b(\d+)\b/ ) {
        $size = $1;
        # These numbers are somewhat arbitrary..
        if( $size > 25 && $size < 55) {
            $size = '55';

This would preserve the current behavior of widening any spec > 25 to at least 55, though at the expense of not allowing widths from 26 to 54. It would enable widths > 55.

I'd go with the original fix since if someone specified 27, we should (at last) deliver 27. And if they they expected 55, it's a trivial fix to their .spec file.

But if you think there's high risk that some important .spec file exists that counts on widening to 55, this is an ultra-conservative alternative.

Pick one...

-- TimotheLitt - 2011-09-14

Thanks Timothe for the report and fix. Your first solution is now in SVN trunk and 5.1 branch. Could you please help test?

In what other places have you seen this issue?

-- TWiki:Main.PeterThoeny - 2011-09-21

As noted above, Type.pm and PASSWORD.pm both have this. I've since found that REGEX has a variant of the bug as well.

# grep -ni -- '55%' `find core/ -type f   | grep -vP '[~#]$' | grep -vP '/\.svn/'`  # Before taking your changes.
core/lib/TWiki/Configure/Type.pm:55:# is a string 55% of the width of the display area.
core/lib/TWiki/Configure/Type.pm:59:    my $size = '55%';
core/lib/TWiki/Configure/Type.pm:64:            $size = '55%';
core/lib/TWiki/Configure/Types/PASSWORD.pm:32:    my $size = '55%';
core/lib/TWiki/Configure/Types/PASSWORD.pm:37:            $size = '55%';
core/lib/TWiki/Configure/Types/REGEX.pm:36:    my $res = '<input name="'.$id.'" type="text" size="55%" value="'.$value.'" />';

COMMAND, PATH, STRING, URL, URLPATH all inherit from Type.pm They inherit the fix, but be aware that spec files that coded previously truncated widths in these will all start working.

Looks good so far on my (small) development config. But you only fixed Type.pm.

  • Type.pm code comment "Default behavior is a string 55% of the width..." should be updated to "Default behavior is a string 55 characters wide".
  • PASSWORD.pm was not updated - same fix needed
  • REGEX.pm has hardcoded 55%, isn't looking at $opts and there's no reason for the hand-coded INPUT field. prompt should be like Type.pm's e.g.
    my $size = 55;
    if( $opts =~ /\b(\d+)\b/ ) {
        $size = $1;
  ...edit $value...
    return CGI::textfield( -name => $id, -size=>$size, -default=>$value );

Of course, there could be cases of this hardcoded in .html, .tmpl - and values other than 55%. I did a partial scan, but was overwhelmed by the noise.

-- TimotheLitt - 2011-09-21

I close this because we build TWiki-5.1.1 today. Please create a new bug item for follow-up work.

-- PeterThoeny - 2012-01-15

Summary Configure: invalid html, restricted input control width
ReportedBy TWiki:Main.TimotheLitt
Codebase ~twiki4, 5.1.0, 4.2.3
SVN Range TWiki-5.1.0, Mon, 12 Sep 2011, build 22279
AppliesTo Engine
Component Configure
Priority Urgent
CurrentState Closed

Checkins TWikirev:22332 TWikirev:22333
TargetRelease patch
ReleasedIn 5.1.1
Edit | Attach | Watch | Print version | History: r8 < r7 < r6 < r5 < r4 | Backlinks | Raw View |  Raw edit | More topic actions
Topic revision: r8 - 2012-01-16 - GeorgeTrubisky
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