Replacing Eval with Object.send and a self written Parser · Ramblings of a build engineer

A while ago, I was added as a curator for a Gem called JsonPath. It’s a small but very useful and brilliant gem. It had a couple of problems which I fixed, but the hardest to eliminate proved to be a series of evals throughout the code.You could opt in using eval with a constructor parameter, but generally, it was considered to be unsafe. Thus, normally when a project was using it, like Huginn they had to opt out by default, thus missing out on sweet parsing like this: $..book[?(@['price'] > 20)].
Replacing Eval with Object.send and a self written Parser · Ramblings of a build engineer #ruby #rubydeveloper #rubyonrails #engineer https://rubyonrails.ba/single/replacing-eval-with-object-send-and-a-self-written-parser-ramblings-of-a-build-engineer

Nezir Zahirovic

Contractor Ruby On Rails (8+ years) / MCPD .Net / C# / Asp.Net / CSS / SQL / (11 years)

related articles