-
-
Notifications
You must be signed in to change notification settings - Fork 2k
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
Properly handle errors originating from included files when compileDebug is enabled #3269
Conversation
pug (3.0.0 → 3.0.1)Bug Fixes
pug-runtime (3.0.0 → 3.0.1)Bug Fixes
Packages With No ChangesThe following packages have no user facing changes, so won't be released:
|
If compileDebug is enabled, a Buffer would be serialized and then pug-runtime would try to split() it assuming it would always be a string.
Thanks for this. The fix will need to be done where we create the Line 167 in 06baa52
I think the best bet would be to move that code into the Line 85 in 06baa52
lex so it would produce a smaller output via not having any non-pug includes.
P.S. the filename should be available as |
@ForbesLindesay Finally had time to revisit this. I also got tired of manually modifying the sources to apply this patch every time my template code has an error just so I can see what it was. :) I moved the Buffer check code to the |
When calling render/compile with
{ compileDebug: true }
, and an error was thrown from (or due to) a local, thestr
parameter inpug_rethrow
was atoJSON()
'dBuffer
, and the rethrow code tried tosplit
it like a string.str
would be something like:which is what happens when you do something like
Buffer.from('foo').toJSON()
.I couldn't really figure out where or how it happens, but I just made the rethrow function gracefully handle those serialized
Buffer
objects properly.I wrote a test that failed (basically just calls an undefined function from an included file):
and then fixed it in this PR.