I just updated the TiddlyWiki. The related javascript macro, I had locked it down to make sure nothing other than `"0123456789 ()+-*/%"` would be accepted, but I had totally forgotten about decimals.
So now the javascript is locked down to make sure nothing other than `"*0123456789 .()+-*/%*"` is accepted. So now this works: `<<EvalThis "{{{ [[25.9]] }}} * ( 1 + ( {{{ [[15%]removesuffix[%]] }}} / 100 ) )">>` i.e. `<<EvalThis "{{ item_price }} * ( 1 + ( {{( [[tax_rate]removesuffix[%]] })} / 100 ) )">>` On Saturday, March 12, 2022 at 2:51:47 PM UTC-4 Charlie Veniot wrote: > After a bit of discussion over on TiddlyTalk > <https://talk.tiddlywiki.org/t/what-are-current-options-for-plain-arithmetic/2699/12>, > > I've resolved a security issue and feel good enough about the little > solution for lengthy/complex (but primitive only) arithmetic expressions. > > In this sample TiddlyWiki instance > <https://cjveniot.neocities.org/TiddlyWikiEvalThisMacro.html>, you'll > find the following two tiddlers needed: > > > - Eval.js (the javascript eval function, locked to only allow the > characters (excluding the double quotes) "0123456789 ()+-*/%" > - EvalThis tiddler with the EvalThis macro. > > > Although I can't stand javascript, I am not fussy about TiddlyWiki filter > operations for lengthy/complex basic arithmetic, and not really fond of > bringing in any of the powerful plugins out there when I don't need that > much oomph. > > Some sample macro references: > > ` > <<EvalThis "(100 + 2) / (9 - 1)">> > > <<EvalThis "59 % 3">> > > <<EvalThis "5**3">> > > <<EvalThis "( {{!!a}} * {{!!b}} ) / 2">> > > <$list filter="[range[25]]"> {{!!title}} / 2 = <<EvalThis "{{!!title}} / > 2">><br> </$list> > ` > > > > -- You received this message because you are subscribed to the Google Groups "TiddlyWiki" group. To unsubscribe from this group and stop receiving emails from it, send an email to tiddlywiki+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/tiddlywiki/b5a17ca8-a7d2-42a9-be4d-67fd8bf36f68n%40googlegroups.com.