Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hosting Command Palette: Trim double quotes from selected items if present #84373

Merged
merged 4 commits into from
Nov 23, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Remove unnecessary trim
  • Loading branch information
Kateryna Kodonenko committed Nov 21, 2023
commit d5e8cd82cf4b15122e3d94e951b49bb5aa29e89f
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,7 @@ function CommandInput( { isOpen, search, setSearch }: CommandInputProps ) {
const commandMenuInput = useRef< HTMLInputElement >( null );
const _value = useCommandState( ( state ) => state.value );
const sanitizedValue = useMemo( () => {
const trimmedValue = _value.trim();
const removedQuotesValue = trimmedValue.replace( /"/g, '' ); // Remove double quotes from any selected items before processing input
const removedQuotesValue = _value.replace( /"/g, '' ); // Remove double quotes from any selected items before processing input
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we use escapeAttribute from @wordpress/escape-html? https://developer.wordpress.org/block-editor/reference-guides/packages/packages-escape-html/#escapeattribute

Or how do we match the sanitization the library is already applying, to make sure our value exactly matches what's rendered on the page?

Also, what other characters might cause problems?

Copy link
Member

@sejas sejas Nov 22, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, what other characters might cause problems?

Yesterday reviewing the PR I found that the double quotes character is problematic. The rest worked fine.

return removedQuotesValue;
}, [ _value ] );

Expand Down
Loading