mirror of
https://github.com/elastic/kibana.git
synced 2025-04-23 17:28:26 -04:00
# Backport This will backport the following commits from `main` to `8.6`: - [Fix useless regex escapes (#150043)](https://github.com/elastic/kibana/pull/150043) <!--- Backport version: 8.9.7 --> ### Questions ? Please refer to the [Backport tool documentation](https://github.com/sqren/backport) <!--BACKPORT [{"author":{"name":"Thomas Watson","email":"watson@elastic.co"},"sourceCommit":{"committedDate":"2023-02-07T16:58:47Z","message":"Fix useless regex escapes (#150043)","sha":"6ad7ba3ddbb6b9445145ebc55f13f54767f5353e","branchLabelMapping":{"^v8.7.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:skip","Team:Fleet","backport:all-open","v8.7.0"],"number":150043,"url":"https://github.com/elastic/kibana/pull/150043","mergeCommit":{"message":"Fix useless regex escapes (#150043)","sha":"6ad7ba3ddbb6b9445145ebc55f13f54767f5353e"}},"sourceBranch":"main","suggestedTargetBranches":[],"targetPullRequestStates":[{"branch":"main","label":"v8.7.0","labelRegex":"^v8.7.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/150043","number":150043,"mergeCommit":{"message":"Fix useless regex escapes (#150043)","sha":"6ad7ba3ddbb6b9445145ebc55f13f54767f5353e"}}]}] BACKPORT--> Co-authored-by: Thomas Watson <watson@elastic.co>
This commit is contained in:
parent
840143e46c
commit
ef976b2798
5 changed files with 25 additions and 5 deletions
|
@ -380,7 +380,7 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|||
if (!opts.axisLabelUseHtml &&
|
||||
navigator.appName == 'Microsoft Internet Explorer') {
|
||||
var ua = navigator.userAgent;
|
||||
var re = new RegExp("MSIE ([0-9]{1,}[\.0-9]{0,})");
|
||||
var re = /MSIE ([0-9]{1,}[.0-9]{0,})/;
|
||||
if (re.exec(ua) != null) {
|
||||
rv = parseFloat(RegExp.$1);
|
||||
}
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
* 2.0.
|
||||
*/
|
||||
|
||||
import { escapeSearchQueryPhrase } from './saved_object';
|
||||
import { escapeSearchQueryPhrase, normalizeKuery } from './saved_object';
|
||||
|
||||
describe('Saved object service', () => {
|
||||
describe('escapeSearchQueryPhrase', () => {
|
||||
|
@ -21,4 +21,24 @@ describe('Saved object service', () => {
|
|||
expect(res).toEqual(`"test1\\"test2"`);
|
||||
});
|
||||
});
|
||||
|
||||
describe('normalizeKuery', () => {
|
||||
it('without attributes postfix', () => {
|
||||
const res = normalizeKuery('foo', 'foo.');
|
||||
|
||||
expect(res).toEqual('foo.attributes.');
|
||||
});
|
||||
|
||||
it('with attributes postfix', () => {
|
||||
const res = normalizeKuery('foo', 'foo.attributes.');
|
||||
|
||||
expect(res).toEqual('foo.attributes.');
|
||||
});
|
||||
|
||||
it('only trigger on literal dots', () => {
|
||||
const res = normalizeKuery('foo', 'foobar');
|
||||
|
||||
expect(res).toEqual('foobar');
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
|
@ -25,7 +25,7 @@ export function escapeSearchQueryPhrase(val: string): string {
|
|||
// filtering SOs
|
||||
export const normalizeKuery = (savedObjectType: string, kuery: string): string => {
|
||||
return kuery.replace(
|
||||
new RegExp(`${savedObjectType}\.(?!attributes\.)`, 'g'),
|
||||
new RegExp(`${savedObjectType}\\.(?!attributes\\.)`, 'g'),
|
||||
`${savedObjectType}.attributes.`
|
||||
);
|
||||
};
|
||||
|
|
|
@ -10,5 +10,5 @@ export const resolvePathVariables = (
|
|||
variables: { [K: string]: string | number }
|
||||
): string =>
|
||||
Object.keys(variables).reduce((acc, paramName) => {
|
||||
return acc.replace(new RegExp(`\{${paramName}\}`, 'g'), String(variables[paramName]));
|
||||
return acc.replace(new RegExp(`\\{${paramName}\\}`, 'g'), String(variables[paramName]));
|
||||
}, path);
|
||||
|
|
|
@ -36,7 +36,7 @@ type FindExceptionListItemOptions = Parameters<ExceptionListClient['findExceptio
|
|||
|
||||
const FILTER_PROPERTY_PREFIX = 'exception-list-agnostic\\.attributes';
|
||||
const FILTER_REGEXP = new RegExp(
|
||||
`^${FILTER_PROPERTY_PREFIX}\.os_types:"([^"]+)"( and \\(${FILTER_PROPERTY_PREFIX}\.tags:"policy:all"( or ${FILTER_PROPERTY_PREFIX}\.tags:"policy:([^"]+)")?\\))?$`
|
||||
`^${FILTER_PROPERTY_PREFIX}\\.os_types:"([^"]+)"( and \\(${FILTER_PROPERTY_PREFIX}\\.tags:"policy:all"( or ${FILTER_PROPERTY_PREFIX}\\.tags:"policy:([^"]+)")?\\))?$`
|
||||
);
|
||||
|
||||
export const mockFindExceptionListItemResponses = (
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue