You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@rocketmq.apache.org by "zjncs (via GitHub)" <gi...@apache.org> on 2026/09/09 08:28:48 UTC
[PR] Escape LIKE wildcards in instance search so names containing _ or % match literally [rocketmq-dashboard]
zjncs opened a new pull request, #4193:
URL: https://github.com/apache/rocketmq-dashboard/pull/4193
### Motivation
The instance search box passes its raw keyword into `LIKE` clauses over `name`, `endpoint` and `remark` (`MybatisPlusInstanceRepository.search` / `findByTypeAndSearch`, reached from `InstanceService.listInstances` for the instance list page). Since `_` and `%` are SQL LIKE wildcards:
- an underscore in an instance name (very common, e.g. `prod_cluster_1`) silently matches *any* single character, so searching `prod_cluster_1` also returns `prod-cluster-1`, `prodXclusterY1`, …
- a trailing `%` (e.g. pasted from a log line) matches every suffix.
So the search can silently return instances that do not contain the typed text at all.
### Changes
- Add a private `escapeLike` helper (same behaviour as the existing `QueryHistoryService.escapeLike`) and apply it to the keyword in both `search` and `findByTypeAndSearch`.
### Verification
`MybatisPlusInstanceRepositoryTest` — two new tests:
- `searchShouldEscapeLikeWildcardsTest`
- `findByTypeAndSearchShouldEscapeLikeWildcardsTest`
Both assert the bound LIKE value for `prod_cluster%` is `%prod\_cluster\%%` and not the unescaped pattern. Before the fix both fail; after it the class is green (18/18).
```
$ mvn -f server/pom.xml test -Dtest='MybatisPlusInstanceRepositoryTest'
(before) Tests run: 18, Failures: 2, Errors: 0
(after) Tests run: 18, Failures: 0, Errors: 0
```
--
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: commits-unsubscribe@rocketmq.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Escape LIKE wildcards in instance search so names containing _ or % match literally [rocketmq-dashboard]
Posted by "lizhimins (via GitHub)" <gi...@apache.org>.
lizhimins commented on PR #4193:
URL: https://github.com/apache/rocketmq-dashboard/pull/4193#issuecomment-5694495198
Closing as part of consolidating the LIKE-escape work — same reasoning as on #4192: a private `escapeLike` copy in the instance repository instead of one shared utility, and no explicit `ESCAPE` clause (the escape relies on MySQL's implicit backslash, which H2 does not provide). #4236 is the anchor we asked to be resubmitted.
--
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: commits-unsubscribe@rocketmq.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Escape LIKE wildcards in instance search so names containing _ or % match literally [rocketmq-dashboard]
Posted by "lizhimins (via GitHub)" <gi...@apache.org>.
lizhimins closed pull request #4193: Escape LIKE wildcards in instance search so names containing _ or % match literally
URL: https://github.com/apache/rocketmq-dashboard/pull/4193
--
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: commits-unsubscribe@rocketmq.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org