Skip to content

Commit

Permalink
[Security Solution] Fix code scanning alert (elastic#198142)
Browse files Browse the repository at this point in the history
Fixes
[https://github.com/elastic/kibana/security/code-scanning/365](https://github.com/elastic/kibana/security/code-scanning/365)

## Summary

To fix the problem, we need to ensure that both double quotes and
backslashes are properly escaped in the `escapeValue` function. This can
be achieved by using a regular expression that replaces both characters
globally. Specifically, we should replace backslashes with double
backslashes (`\\`) and double quotes with escaped double quotes (`\"`).

- Update the `escapeValue` function to use a regular expression that
handles both double quotes and backslashes.
- Ensure that the regular expression has the global flag (`g`) to
replace all occurrences of the characters.

Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
  • Loading branch information
1 parent fdd5e0b commit b9a5d6a
Showing 1 changed file with 1 addition and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ const COPY_TO_CLIPBOARD_SUCCESS = i18n.translate(
}
);

const escapeValue = (value: string) => value.replace(/"/g, '\\"');
const escapeValue = (value: string) => value.replace(/\\/g, '\\\\').replace(/"/g, '\\"');

export const createCopyToClipboardActionFactory = createCellActionFactory(
({ notifications }: { notifications: NotificationsStart }) => ({
Expand Down

0 comments on commit b9a5d6a

Please sign in to comment.