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 2015/06/12 14:19:28 UTC
[2/2] ambari git commit: AMBARI-11875 Yarn config tab doesn't load
with Oracle 12. (atkach)
AMBARI-11875 Yarn config tab doesn't load with Oracle 12. (atkach)
Project: http://git-wip-us.apache.org/repos/asf/ambari/repo
Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/ed936045
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/ed936045
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/ed936045
Branch: refs/heads/branch-2.1
Commit: ed93604537fb6c0f6b6024586c60d46f762ad067
Parents: b1da897
Author: Andrii Tkach <at...@hortonworks.com>
Authored: Fri Jun 12 15:03:45 2015 +0300
Committer: Andrii Tkach <at...@hortonworks.com>
Committed: Fri Jun 12 15:18:48 2015 +0300
----------------------------------------------------------------------
ambari-web/app/utils/configs/database.js | 5 +++--
ambari-web/app/utils/string_utils.js | 10 ++++++++++
ambari-web/test/utils/configs/database_test.js | 12 ++++++++++++
3 files changed, 25 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ambari/blob/ed936045/ambari-web/app/utils/configs/database.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/utils/configs/database.js b/ambari-web/app/utils/configs/database.js
index 2ee3f65..6dde0fa 100644
--- a/ambari-web/app/utils/configs/database.js
+++ b/ambari-web/app/utils/configs/database.js
@@ -17,6 +17,7 @@
*/
var validators = require('utils/validator');
+var stringUtils = require('utils/string_utils');
/**
* Helper methods to process database values and properties
* @module utils/configs/database
@@ -53,7 +54,7 @@ module.exports = {
mssql: 'jdbc:sqlserver://{0};databaseName={1}',
postgres: 'jdbc:postgresql://{0}:5432/{1}',
derby: 'jdbc:derby:{0}/{1}',
- oracle: 'jdbc:oracle:thin:@//{0}:1521/{1}'
+ oracle: 'jdbc:oracle:thin:@(?:\/?\/?){0}:1521(\:|\/){1}'
},
/**
@@ -180,7 +181,7 @@ module.exports = {
result.location = this.getDBLocationFromJDBC(jdbcUrl);
if (!jdbcUrl.endsWith('{1}')) {
- dbName = jdbcUrl.replace(this.DB_JDBC_PATTERNS[result.dbType].format(result.location,''), '');
+ dbName = jdbcUrl.replace(new RegExp(this.DB_JDBC_PATTERNS[result.dbType].format(stringUtils.escapeRegExp(result.location),'')), '');
if (dbName) {
result.databaseName = dbName.split(/[;|?]/)[0];
}
http://git-wip-us.apache.org/repos/asf/ambari/blob/ed936045/ambari-web/app/utils/string_utils.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/utils/string_utils.js b/ambari-web/app/utils/string_utils.js
index d38fb29..48f8e52 100644
--- a/ambari-web/app/utils/string_utils.js
+++ b/ambari-web/app/utils/string_utils.js
@@ -214,5 +214,15 @@ module.exports = {
htmlEntities: function (string) {
if (typeof string !== 'string') return "";
return $("<div/>").text(string).html();
+ },
+
+ /**
+ * Escaping user input to be treated as a literal string within a regular expression
+ * get from https://developer.mozilla.org/en/docs/Web/JavaScript/Guide/Regular_Expressions
+ * @param {string} str
+ * @returns {*}
+ */
+ escapeRegExp: function (str) {
+ return str.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
}
};
http://git-wip-us.apache.org/repos/asf/ambari/blob/ed936045/ambari-web/test/utils/configs/database_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/utils/configs/database_test.js b/ambari-web/test/utils/configs/database_test.js
index de95750..85ed35c 100644
--- a/ambari-web/test/utils/configs/database_test.js
+++ b/ambari-web/test/utils/configs/database_test.js
@@ -47,6 +47,10 @@ describe('Database Utils', function() {
e: 'localhost.com'
},
{
+ jdbcUrl: 'jdbc:oracle:thin:@ec2-52-5-27-33.compute-1.amazonaws.com:1521:ORCL',
+ e: 'ec2-52-5-27-33.compute-1.amazonaws.com'
+ },
+ {
jdbcUrl: 'jdbc:oracle:thin:@//{0}:1521/{1}',
e: null
}
@@ -116,6 +120,14 @@ describe('Database Utils', function() {
}
},
{
+ jdbcUrl: 'jdbc:oracle:thin:@localhost.com:1521:someDb',
+ e: {
+ dbType: 'oracle',
+ location: 'localhost.com',
+ databaseName: 'someDb'
+ }
+ },
+ {
jdbcUrl: 'jdbc:oracle:thin:@//{0}:1521/{1}',
e: {
dbType: 'oracle',