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
| Comment | File | Size | Author |
|---|---|---|---|
| #10 | 3293474-10--search_field_max_length.patch | 2.66 KB | drunken monkey |
Issue fork search_api-3293474
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
Comment #3
jhedstromComment #4
jhedstromAdding a patch for use by composer.
Comment #5
finex commentedHi, the patch works fine. Thank you.
Comment #6
drunken monkeyThanks 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?
Comment #7
admirlju commentedAs 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).
Comment #9
admirlju commentedAdded a simple config, to set the max length and it defaults to 128. An empty value means no limit.
Comment #10
drunken monkeyThanks, 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.
Comment #11
finex commentedI like the patch, +1 :-)
Comment #12
admirlju commentedIt 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.
Comment #14
drunken monkeyGood to hear, thanks for testing/reviewing!
Committed. Thanks again, everyone!