jokerzsd opened a new pull request, #4393:
URL: https://github.com/apache/rocketmq-dashboard/pull/4393
Replaces #4363, closed by the `rocketmq-studio` → `master` branch switch.
(Also a resubmit of #4236 per @lizhimins's review.)
## Summary
User-supplied search strings in topic/group metadata search and data source
search were passed into MyBatis-Plus `like()`, so `%`, `_` and `\` were treated
as SQL wildcards/escape characters. The prior fix escaped the value but relied
on MySQL's implicit backslash escape character, which is wrong on H2 (no
default LIKE escape character).
## Fix
- Add a shared `SqlLikeUtils` helper (`escape` + `contains` + the `ESCAPE`
clause constant).
- Replace the five `.like()` predicates with `.apply(..., "name LIKE {0}
ESCAPE '\'", SqlLikeUtils.contains(search))` (four in
`RocketMQMetadataProvider`, one in
`MybatisPlusSettingsRepository.findDataSources`), so the backslash is
explicitly the escape character on every dialect.
## Tests
-
`RocketMQMetadataProviderTest.searchEscapesLikeWildcardsAndAddsExplicitEscapeClause`:
asserts the wrapper contains `LIKE`/`ESCAPE` and the bound parameter is
`%prod\_user%` for both topic and group search.
-
`MybatisPlusSettingsRepositoryTest.findDataSourcesEscapesSearchWildcardsAndAddsEscapeClause`:
same assertion for the data source search.
## Verification
`mvn test -Dtest=RocketMQMetadataProviderTest` → 42 passed.
`mvn test -Dtest=MybatisPlusSettingsRepositoryTest` → 11 passed.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]