@@ -253,7 +253,9 @@ function set_timer_interval(interval) {
253253}
254254
255255function reset_timer ( ) {
256- clearInterval ( timer ) ;
256+ if ( timer != null ) {
257+ clearInterval ( timer ) ;
258+ }
257259 if ( timer_interval != null ) {
258260 timer = setInterval ( partial_update , timer_interval ) ;
259261 }
@@ -733,13 +735,31 @@ function postprocess() {
733735 update_multifields ( ) ;
734736}
735737
738+ function is_valid_regexp ( value ) {
739+ try {
740+ var _ = new RegExp ( value , 'i' ) ;
741+ return true ;
742+ } catch ( e ) {
743+ return false ;
744+ }
745+ }
746+
736747function url_pagination_template_context ( template , context , defaultPage , defaultPageSize ) {
737748 var page_number_request = fmt_page_number_request ( context , defaultPage ) ;
738749 var page_size = fmt_page_size_request ( context , defaultPageSize ) ;
739750 var name_request = fmt_filter_name_request ( context , "" ) ;
740751 var use_regex = fmt_regex_request ( context , "" ) == "checked" ;
741752 if ( use_regex ) {
742- name_request = esc ( name_request ) ;
753+ // rabbitmq/rabbitmq-server#8008: if the expression cannot be compiled to a reg exp,
754+ // assume a regular text filter
755+ var valid_regexp = is_valid_regexp ( name_request ) ;
756+ if ( ! valid_regexp ) {
757+ show_popup ( 'warn' , fmt_escape_html ( `Filter expression '${ name_request } ' is not a valid regular expression, will perform a regular text query` ) ) ;
758+ use_regex = false ;
759+ }
760+ if ( use_regex && valid_regexp ) {
761+ name_request = esc ( name_request ) ;
762+ }
743763 }
744764 return '/' + template +
745765 '?page=' + page_number_request +
0 commit comments