Skip to content

Commit

Permalink
OOZIE-3718 Improve Oozie Web UI filtering (NikhilDaf via dionusos)
Browse files Browse the repository at this point in the history
  • Loading branch information
dionusos committed Oct 19, 2023
1 parent 3c614c7 commit 318fac5
Showing 1 changed file with 28 additions and 6 deletions.
34 changes: 28 additions & 6 deletions webapp/src/main/webapp/oozie-console.js
Original file line number Diff line number Diff line change
Expand Up @@ -204,8 +204,30 @@ function getCustomFilter() {
return filter;
}

function convertStatusToUpperCase(filterText) {
var converted = filterText.replace(/status=([a-zA-Z]+)/g, function(){
// code imported and modified from Handlebars escapeExpression utility
const escape = {
'&': '&',
'<': '&lt;',
'>': '&gt;',
'`': '&#x60;',
};

function escapeChar(chr) {
return escape[chr];
}

const badChars = /[&<>`]/g,
possible = /[&<>`]/;

function escapeExpression(text) {
if (!possible.test(text)) {
return text;
}
return text.replace(badChars, escapeChar);
}

function convertStatusToUpperCaseAndEscapeHtml(filterText) {
var converted = escapeExpression(filterText).replace(/status=([a-zA-Z]+)/g, function(){
var text = arguments[1];
return "status="+ text.toUpperCase();
});
Expand Down Expand Up @@ -2618,7 +2640,7 @@ var changeFilterAction = new Ext.Action({
handler: function() {
Ext.Msg.prompt('Filter Criteria', 'Filter text:', function(btn, text) {
if (btn == 'ok' && text) {
var filter = convertStatusToUpperCase(text);
var filter = convertStatusToUpperCaseAndEscapeHtml(text);
refreshCustomJobsAction.setText(filter);
Ext.state.Manager.setProvider(new Ext.state.CookieProvider({
expires: new Date(new Date().getTime()+315569259747)
Expand All @@ -2637,7 +2659,7 @@ var changeCoordFilterAction = new Ext.Action({
handler: function() {
Ext.Msg.prompt('Filter Criteria', 'Filter text:', function(btn, text) {
if (btn == 'ok' && text) {
var filter = convertStatusToUpperCase(text);
var filter = convertStatusToUpperCaseAndEscapeHtml(text);
refreshCoordCustomJobsAction.setText(filter);
Ext.state.Manager.setProvider(new Ext.state.CookieProvider({
expires: new Date(new Date().getTime()+315569259747)
Expand All @@ -2656,7 +2678,7 @@ var changeBundleFilterAction = new Ext.Action({
handler: function() {
Ext.Msg.prompt('Filter Criteria', 'Filter text:', function(btn, text) {
if (btn == 'ok' && text) {
var filter = convertStatusToUpperCase(text);
var filter = convertStatusToUpperCaseAndEscapeHtml(text);
refreshBundleCustomJobsAction.setText(filter);
Ext.state.Manager.setProvider(new Ext.state.CookieProvider({
expires: new Date(new Date().getTime()+315569259747)
Expand Down Expand Up @@ -3231,7 +3253,7 @@ function initConsole() {
Ext.state.Manager.setProvider(new Ext.state.CookieProvider({
expires: new Date(new Date().getTime()+315569259747) // about 10 years from now!
}));
var upper_value = convertStatusToUpperCase(value);
var upper_value = convertStatusToUpperCaseAndEscapeHtml(value);
Ext.state.Manager.set("GlobalCustomFilter", upper_value);
}
}}
Expand Down

0 comments on commit 318fac5

Please sign in to comment.