-
Notifications
You must be signed in to change notification settings - Fork 3.4k
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
feat: add disablePlugins
flag for render() options
#3701
Conversation
@@ -149,12 +149,22 @@ const Parser = function Parser(context, imports, fileInfo) { | |||
// | |||
parse: function (str, callback, additionalData) { | |||
let root; | |||
let error = null; | |||
let err = null; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note: Had to rename this, as it was shadowing the error
function.
@broofa this is amazing! So helpful for our usecase. Forgive my ignorance with JS, but we currently invoke this module via:
Would this PR introduce a command line arg like this Thanks! |
@matthew-gill heh... I actually misread your comment as "can you help add it" and so just added support for a
That said, we (CodePen) don't have an immediate need for this; we're just using the programmatic JS API. I'm happy to revert the CLI flag support. (Might be a good idea, to avoid complicating the CLI interface unnecessarily?) Thoughts? |
@broofa oh wow! Thanks for doing this! |
@broofa https://github.com/less/less-docs , docs repo is standalone. Thanks for your contribution, great idea and implemention. 👍 |
Of course. Is anything else needed here, then? Would love to see this merged and published sometime in the not-too-distant future, but it's not urgent. |
Thoughts on how difficult this would be to backport to |
We'd love it backported to 3 too - we're in the same boat as you @broofa. (P.s. thank you for working on this, it's really appreciated!!) |
Co-authored-by: Edward Hartwell Goose <edhgoose@users.noreply.github.com>
@matthew-dean: Are you the right person to nag about the status of this? I've discovered yet another down-side to being on our own fork of |
Hi all. A few notes about this. One is that probably this should be Next, yes, I would support it at the lessc level. Ideally, all option flags in Finally, re: backporting to 3.0. The main reason for the 4.0 release is that It's basically the same as 3.0 other than that. So, no, I don't think backporting is a good option. What I would do for CodePen, if it were me, is to not make this breaking change, just use 4.0, but set Less's options to be |
I've renamed
👍
Sounds good. I'll run this by folks here to see if there are any issues on our end and circle back if so. In the meantime, if we could get this out for 4.x, that would be awesome. Let me know if you need anything else here. |
FYI, the consensus here (codepen) is that we can work around the |
@matthew-dean Sweet! Thanks for taking this. Any idea when the next release will go out? |
Is there any reason to disable both I would like use plugins enabled from outside (CLI or options), but keep |
What:
Adds support for a
options.disablePlugins
flag on theless.render()
method. Setting this to true disables parsing of@plugin
statements and, instead, throws an error.Why:
As
@plugin
statements may be used to run arbitrary system commands. This is a significant security risk for applications that need to process untrusted code. At a minimum, applications should be able to disable parsing of@plugin
statements.As noted by my colleague @shshaw here at CodePen, we ended up forking this repo so we could disable
@plugin
processing. Adding this option will allow us and our users to stay current with the officialless
codepase.See also:
How:
Calling
less.render(inputString, {disablePlugins: true})
activates the new codepath. With this option enabled, theparsers.plugin()
method is replaced with one that failes with an error when an@plugin
statement is detected.Checklist: