Merge pull request #540 from TeamPiped/query-length-check

Add check for query length.
This commit is contained in:
Kavin 2023-03-04 03:04:28 +00:00 committed by GitHub
commit e352d55ce9
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -28,6 +28,9 @@ public class SearchHandlers {
if (StringUtils.isEmpty(query))
ExceptionHandler.throwErrorResponse(new InvalidRequestResponse("query is a required parameter"));
if (query.length() > 100)
ExceptionHandler.throwErrorResponse(new InvalidRequestResponse("query is too long"));
return mapper.writeValueAsBytes(YOUTUBE_SERVICE.getSuggestionExtractor().suggestionList(query));
}
@ -38,6 +41,9 @@ public class SearchHandlers {
if (StringUtils.isEmpty(query))
ExceptionHandler.throwErrorResponse(new InvalidRequestResponse("query is a required parameter"));
if (query.length() > 100)
ExceptionHandler.throwErrorResponse(new InvalidRequestResponse("query is too long"));
return mapper.writeValueAsBytes(Arrays.asList(
query,
YOUTUBE_SERVICE.getSuggestionExtractor().suggestionList(query)