Skip to content

TextField: Have a maxLength by default initialization because it is abusable #1602

Description

@mkemmerz

I noticed that a TextField has no maxLength by default and if a user puts in a stupidly huge amount of characters in the TextField the frontend of my application freezes and does nothing for a a long time (depending on the amount of characters). The backend is not effected by it. I know it is very unlikely that a user enters such a huge amount (> x000k of characters) in a textfield but you know, nothing is impossible.

Version: Vaadin.14.0.15

`public class TestView extends HorizontalLayout {

public TestView() {
    TextField t = new TextField();

    t.addValueChangeListener(event -> {
        System.out.println(event.getValue().length());
    });

    add(t);
}

}`

Prints:

238
4998
364854

After the 364k*x characters the frontend froze.

I would like to prevent the abusing of the TextField's for my whole application but instead of doing textfield.setMaxLength() for every textfield a limitation by default sounds reasonable to me. I know that I can achieve this using an own textfield-superclass but was this issue ever discussed here?

tl;dr What about the enhancement that TextFields have a default maxLength because you can abuse it by entering a very huge amount of characters?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions