You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by at...@apache.org on 2016/11/01 11:58:55 UTC
ambari git commit: AMBARI-18759 Search functionality on Alerts page
fails to retrieve alert definitions with parenthesis in the name. (atkach)
Repository: ambari
Updated Branches:
refs/heads/trunk 334d4ccd3 -> 754186f9b
AMBARI-18759 Search functionality on Alerts page fails to retrieve alert definitions with parenthesis in the name. (atkach)
Project: http://git-wip-us.apache.org/repos/asf/ambari/repo
Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/754186f9
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/754186f9
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/754186f9
Branch: refs/heads/trunk
Commit: 754186f9ba4b3da0db14cace1e765707b6ceab64
Parents: 334d4cc
Author: Andrii Tkach <at...@apache.org>
Authored: Tue Nov 1 11:46:38 2016 +0200
Committer: Andrii Tkach <at...@apache.org>
Committed: Tue Nov 1 13:22:15 2016 +0200
----------------------------------------------------------------------
ambari-web/app/utils/validator.js | 2 +-
ambari-web/app/views/common/filter_view.js | 3 ++-
ambari-web/test/utils/validator_test.js | 3 ++-
ambari-web/test/views/common/filter_view_test.js | 5 +++++
4 files changed, 10 insertions(+), 3 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ambari/blob/754186f9/ambari-web/app/utils/validator.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/utils/validator.js b/ambari-web/app/utils/validator.js
index 7b08d37..48ba4dd 100644
--- a/ambari-web/app/utils/validator.js
+++ b/ambari-web/app/utils/validator.js
@@ -254,7 +254,7 @@ module.exports = {
return true;
};
if (/^[\?\|\*\!,]/.test(value)) return false;
- return /^((\.\*?)?([\w\s\[\]\/\?\-_,\|\*\!\{\}]*)?)+(\.\*?)?$/g.test(value) && (checkPair(['[',']'])) && (checkPair(['{','}']));
+ return /^((\.\*?)?([\w\s\[\]\/\?\-_,\|\*\!\{\}\(\)]*)?)+(\.\*?)?$/g.test(value) && (checkPair(['[',']'])) && (checkPair(['{','}']));
},
/**
http://git-wip-us.apache.org/repos/asf/ambari/blob/754186f9/ambari-web/app/views/common/filter_view.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/views/common/filter_view.js b/ambari-web/app/views/common/filter_view.js
index 56f68e5..8110d80 100644
--- a/ambari-web/app/views/common/filter_view.js
+++ b/ambari-web/app/views/common/filter_view.js
@@ -594,7 +594,8 @@ module.exports = {
default:
return function (origin, compareValue) {
if (validator.isValidMatchesRegexp(compareValue)) {
- var regex = new RegExp(compareValue, "i");
+ var escapedCompareValue = compareValue.replace("(", "\\(").replace(")", "\\)").trim();
+ var regex = new RegExp(escapedCompareValue, "i");
return regex.test(origin);
}
return false;
http://git-wip-us.apache.org/repos/asf/ambari/blob/754186f9/ambari-web/test/utils/validator_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/utils/validator_test.js b/ambari-web/test/utils/validator_test.js
index f542c7a..2a30993 100644
--- a/ambari-web/test/utils/validator_test.js
+++ b/ambari-web/test/utils/validator_test.js
@@ -422,7 +422,8 @@ describe('validator', function () {
{ value: '[a1', expected: false },
{ value: 'a{1}', expected: true },
{ value: 'a{1,2}', expected: true },
- { value: 'a{1,2}{', expected: false }
+ { value: 'a{1,2}{', expected: false },
+ { value: 'a(1)', expected: true }
];
tests.forEach(function(test) {
it(message.format(test.value, test.expected ? 'valid' : 'not valid'), function() {
http://git-wip-us.apache.org/repos/asf/ambari/blob/754186f9/ambari-web/test/views/common/filter_view_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/views/common/filter_view_test.js b/ambari-web/test/views/common/filter_view_test.js
index 0ae1ca3..0590b4c 100644
--- a/ambari-web/test/views/common/filter_view_test.js
+++ b/ambari-web/test/views/common/filter_view_test.js
@@ -373,6 +373,11 @@ describe('filters.getFilterByType', function () {
result: true
},
{
+ condition: 'lo (1)',
+ value: 'hello (1)',
+ result: true
+ },
+ {
condition: 'lol',
value: 'hello',
result: false