This is a question about the safety of Liquid, with the DotLiquid library.
Suppose my view model is something like following (pseudocode):
class MyViewModel
public string MyField
public string MyMethod()
...and a MyViewModel object is passed to the Liquid template, where MyField is set to be accessible from within the template (so the template can read its content).
- Can MyField be assigned to? I.e. can the template modify the contents of the view model?
- Can MyMethod() be called? No "MyMethod" member is configured as being accessible from the template when rendering it.
- What would happen if the "MyMethod" member would be configured to be accessible when rendering the template? Are method calls possible from Liquid templates?
My assumption is that the answer is no to all of the questions but I'd like to be sure.
Thank you.
MyField
can't be assigned to. In fact, it can't be accessed at all - only public instance methods and properties are accessible in DotLiquid.Drop
class, then all public instance methods and properties will be accessible.Drop
, then you'll probably be using theTemplate.RegisterSafeType(Type type, string[] allowedMembers)
method, which requires you to tell DotLiquid which properties and methods can be accessed (using theallowedMembers
parameter).