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

fix(treesitter): validate language name #22005

Merged
merged 1 commit into from
Jan 31, 2023
Merged

Conversation

clason
Copy link
Member

@clason clason commented Jan 26, 2023

Problem

Some injections (like markdown) allow specifying arbitrary language names for code blocks, which may lead to errors when looking for a corresponding parser with the same name in runtimepath.

Solution

Validate that the language name only contains alphanumeric characters and _ (e.g., for c_sharp) and error otherwise.

Alternative approach

lang:gsub('%W',''), but that would also strip _, which is used for a number of language names in nvim-treesitter.

Closes #21485
Supersedes #21943

@bfredl @stsewd

@clason clason marked this pull request as draft January 26, 2023 08:46
@marvim marvim requested a review from a team January 26, 2023 08:46
@clason clason force-pushed the sanitize-lang branch 2 times, most recently from 0e00ece to 4c559e2 Compare January 26, 2023 15:00
@clason clason added this to the 0.8.3 milestone Jan 27, 2023
@clason clason marked this pull request as ready for review January 28, 2023 10:23
Problem: Some injections (like markdown) allow specifying arbitrary
language names for code blocks, which may be lead to errors when
looking for a corresponding parser in runtime path.

Solution: Validate that the language name only contains alphanumeric
characters and `_` (e.g., for `c_sharp`) and error otherwise.
@clason clason requested a review from bfredl January 28, 2023 12:00
@clason clason merged commit 8b11cf5 into neovim:master Jan 31, 2023
@clason
Copy link
Member Author

clason commented Jan 31, 2023

Standard meeting rules: approved by silent acclamation.

@github-actions
Copy link
Contributor

Successfully created backport PR #22074 for release-0.8.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

vim.treesitter.language.require_language('{foo}') errors with E219: Missing {
2 participants