summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Klishin <klishinm@vmware.com>2023-04-27 19:02:19 +0400
committerGitHub <noreply@github.com>2023-04-27 19:02:19 +0400
commit22df133e4602e0ae53e79719043f3c7178400b09 (patch)
tree947c040c1c00cee3e43eab7935d7113eb7be40a1
parent608026c04e4fb8d0ef79aea1e0b025271919e0a5 (diff)
parenta5449a44575360978627d502038bffe2b3eb82d4 (diff)
downloadrabbitmq-server-git-22df133e4602e0ae53e79719043f3c7178400b09.tar.gz
Merge pull request #8028 from rabbitmq/mergify/bp/v3.9.x/pr-8027
Management UI: handle invalid regular expressions in filters when switching tabs (backport #8010) (backport #8023) (backport #8026) (backport #8027)
-rw-r--r--deps/rabbitmq_management/priv/www/js/global.js5
-rw-r--r--deps/rabbitmq_management/priv/www/js/main.js24
2 files changed, 24 insertions, 5 deletions
diff --git a/deps/rabbitmq_management/priv/www/js/global.js b/deps/rabbitmq_management/priv/www/js/global.js
index 075c069150..5097c6f43e 100644
--- a/deps/rabbitmq_management/priv/www/js/global.js
+++ b/deps/rabbitmq_management/priv/www/js/global.js
@@ -486,8 +486,7 @@ var HELP = {
'filter-regex' :
'Whether to enable regular expression matching. Both string literals \
- and regular expressions are matched in a case-insensitive manner.<br/><br/> \
- (<a href="https://developer.mozilla.org/en/docs/Web/JavaScript/Guide/Regular_Expressions" target="_blank">Regular expression reference</a>)',
+ and regular expressions are matched in a case-insensitive manner.<br/><br/>',
'consumer-active' :
'Whether the consumer is active or not, i.e. whether the consumer can get messages from the queue. \
@@ -497,7 +496,7 @@ var HELP = {
(<a href="https://www.rabbitmq.com/consumers.html#active-consumer" target="_blank">Documentation</a>)',
'consumer-owner' :
- '<a href="https://www.rabbitmq.com/consumers.html">AMQP consumers</a> belong to an AMQP channel, \
+ '<a href="https://www.rabbitmq.com/consumers.html">AMQP 0-9-1 consumers</a> belong to a channel, \
and <a href="https://www.rabbitmq.com/stream.html">stream consumers</a> belong to a stream connection.',
'plugins' :
diff --git a/deps/rabbitmq_management/priv/www/js/main.js b/deps/rabbitmq_management/priv/www/js/main.js
index 5ef8e56edf..7572563faa 100644
--- a/deps/rabbitmq_management/priv/www/js/main.js
+++ b/deps/rabbitmq_management/priv/www/js/main.js
@@ -278,7 +278,9 @@ function set_timer_interval(interval) {
}
function reset_timer() {
- clearInterval(timer);
+ if (timer != null) {
+ clearInterval(timer);
+ }
if (timer_interval != null) {
timer = setInterval(partial_update, timer_interval);
}
@@ -741,13 +743,31 @@ function postprocess() {
update_multifields();
}
+function is_valid_regexp(value) {
+ try {
+ var _ = new RegExp(value, 'i');
+ return true;
+ } catch (e) {
+ return false;
+ }
+}
+
function url_pagination_template_context(template, context, defaultPage, defaultPageSize){
var page_number_request = fmt_page_number_request(context, defaultPage);
var page_size = fmt_page_size_request(context, defaultPageSize);
var name_request = fmt_filter_name_request(context, "");
var use_regex = fmt_regex_request(context, "") == "checked";
if (use_regex) {
- name_request = esc(name_request);
+ // rabbitmq/rabbitmq-server#8008: if the expression cannot be compiled to a reg exp,
+ // assume a regular text filter
+ var valid_regexp = is_valid_regexp(name_request);
+ if (!valid_regexp) {
+ show_popup('warn', fmt_escape_html(`Filter expression '${name_request}' is not a valid regular expression, will perform a regular text query`));
+ use_regex = false;
+ }
+ if (use_regex && valid_regexp) {
+ name_request = esc(name_request);
+ }
}
return '/' + template +
'?page=' + page_number_request +