Problem/Motivation

Since the SearchApiFulltext filter plugin extends the core text input, the maxlength for the input is set to 128 characters.

This is similar to the core issue for the views exposed text input. #3119290: Search by title is capped to 128 characters limit

Steps to reproduce

Use the filter and try to input text greater than 128 characters.

Proposed resolution

Remove the maxlength attribute from the input.

Remaining tasks

Issue fork search_api-3293474

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

jhedstrom created an issue. See original summary.

jhedstrom’s picture

Status: Active » Needs review
jhedstrom’s picture

StatusFileSize
new751 bytes

Adding a patch for use by composer.

finex’s picture

Status: Needs review » Reviewed & tested by the community

Hi, the patch works fine. Thank you.

drunken monkey’s picture

Status: Reviewed & tested by the community » Needs review

Thanks for opening this issue, sounds like a good idea! Sorry for taking so long to respond, I had a pretty large backlog …

In any case, you’re right, while 128 characters is probably enough in most situations, no reason to limit to that by default.
However, I do wonder whether we shouldn’t just raise the limit instead of completely removing it, or make this configurable, to guard against attackers submitting massive fulltext queries to overload the search server. What’s your opinion on that?

admirlju’s picture

As mentioned in the patch comment, the reason behind 128 is that in the core that is the default max length for textfields. However, I did find this issue #3331028: Increase default textfield #maxlength=128 to 256 where they are already planning to either remove the maxlimit or increase it to 256.

When it comes to this module, I personally also don't think it's smart to just remove the limit at least not by default, as @drunken monkey already also pointed out, it does work as a guard against attackers. I would either just increase the limit to something like 256 or at max 512, or make it configurable (where the default value is still 128).

admirlju’s picture

StatusFileSize
new2.27 KB

Added a simple config, to set the max length and it defaults to 128. An empty value means no limit.

drunken monkey’s picture

StatusFileSize
new3.72 KB
new2.66 KB

Thanks, looks great!
However, since this option should only affect the exposed form, it’s probably better to move it to that part of the filter options form. I also rephrased the label and description a bit, hope this is clearer.
Everyone, please test/review! This otherwise looks ready to be committed to me.

finex’s picture

I like the patch, +1 :-)

admirlju’s picture

Status: Needs review » Reviewed & tested by the community

It looks good to me. This way people can disable/increase the limit if they want to. Didn't break any other functionality in my testing so it can probably be merged.

drunken monkey’s picture

Status: Reviewed & tested by the community » Fixed

Good to hear, thanks for testing/reviewing!
Committed. Thanks again, everyone!

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.