Open anseki opened 9 years ago
Sorry, I did not write test. I have no time now.
I found another problem that is caused by this bug. For example:
To easy change a style of a specific text by a specific CSS class.
<!-- @exec showWithClass('Back to ABOUT, HOME, NEWS or EVENTS', 'warning') -->
Desired Result:
<span class="warning">Back to ABOUT, HOME, NEWS or EVENTS</span>
// shallow copy of ENV
var context = Object.keys(process.env).reduce(
function(env, prop) { env[prop] = process.env[prop]; return env; }, {});
// add function
context.showWithClass = function(text, className) {
return '<span class="' + className + '">' + text + '</span>';
// In actuality, do something more. Otherwise, @echo is good enough.
};
console.log(require('preprocess').preprocess(html, context));
Result:
<span class="/home/USERNAME">undefined</span>
Because a quoted text was split by commas, HOME
environment variable was shown. And a text was lost.
This PR solves this problem too.
The string parameters that include the quotes or commas are not parsed correctly.
For example:
Result:
0, 1, 2, 3 are OK. But others are not and number of parameters is incorrect.
Result by fixed code: