cl-mustache icon indicating copy to clipboard operation
cl-mustache copied to clipboard

Errors when calling one print-data method from another.

Open FrankRuben opened this issue 10 years ago • 1 comments

Hi Kanru,

first of all thanks for the library!

When I incorrectly created the mustache environment using something like '((key value)) instead of '((key . value)), I was hit by an error that the escape flag for {{{...}}} had not been correctly evaluated, means that even for the triple-pattern, escape was called. It turned out that the incorrect environment did lead to the call of '(defmethod print-data (token escapep &optional context) ...)' and that this method forwarded processing to another print-data method with incorrect arguments: instead of calling '(print-data (princ-to-string token) (%output))' I think it's necessary to call '(print-data (princ-to-string token) escapep context)'. The incorrect call passed the stream %output as escape a non-nil flag, so that escape was always called, whereas the proposed fixed won't do this. (Also the context argument was missing.)

While searching, I also found that also '(defmethod print-data ((data symbol) escapep &optional context) ...)' does not pass the context parameter and I think it is necessary to change the body to '(print-data (string data) escapep context)'.

HTH and best regards, Frank

FrankRuben avatar Jul 20 '14 16:07 FrankRuben

Hi Frank,

Thanks for reporting! For the first issue could you provide a example? I'm considering to add APIs for building contexts in order to prevent such mistakes.

The second issue I think is fixed in 795ba18f1eb38fe68f so please check with latest release and see if it's fixed.

kanru avatar Jul 22 '14 03:07 kanru