This is a note to make aware of some unexpected behavior I found while testing functions systematically.
I made some notes on this but never posted an issue. Still pondering what the general approach should be for sanitizing user input data and types in the autogenerated methods. I have some tools that I have been working for checking the arg string that might be able to be dropped into all of the generated code.
This is an analogue of #20 where arguments plopped into shell can lead to unexpected results. In this issue the shell does not like the parentheses floating around unquoted.
This wbt_laplacian_filter() behavior shows up as Syntax error: "(" unexpected
Fix: Default variant user argument needs to be wrapped in shQuote(). It will fail with the default value "3x3(1)" . A heavy-handed solution might be to shQuote all "OptionList" parameter types. I say heavy handed because it might not happen all that frequently. At a minimum any default arguments should be quoted so they dont error, ~but probably it should just quote the argument, which would only affect people who may have come up with their own workaround.~ Note: WBT should handle extra quotes for arguments fine, it replaces anything that evaluates to " or ' with nothing.
Of the other OptionList cases (n=5) where the variant parameter name is used wbt_laplacian_filter() is the only one that is sensitive to this bug because of the parentheses in the option labels.
This is a note to make aware of some unexpected behavior I found while testing functions systematically.
I made some notes on this but never posted an issue. Still pondering what the general approach should be for sanitizing user input data and types in the autogenerated methods. I have some tools that I have been working for checking the arg string that might be able to be dropped into all of the generated code.
This is an analogue of #20 where arguments plopped into shell can lead to unexpected results. In this issue the shell does not like the parentheses floating around unquoted.
This
wbt_laplacian_filter()
behavior shows up asSyntax error: "(" unexpected
Fix: Default
variant
user argument needs to be wrapped inshQuote()
. It will fail with the default value"3x3(1)"
. A heavy-handed solution might be to shQuote all "OptionList" parameter types. I say heavy handed because it might not happen all that frequently. At a minimum any default arguments should be quoted so they dont error, ~but probably it should just quote the argument, which would only affect people who may have come up with their own workaround.~ Note: WBT should handle extra quotes for arguments fine, it replaces anything that evaluates to"
or'
with nothing.Of the other OptionList cases (n=5) where the
variant
parameter name is usedwbt_laplacian_filter()
is the only one that is sensitive to this bug because of the parentheses in the option labels.Fix (to be done in a general way)
Change
where
variant
toSo that
--run=laplacian_filter --input=DEM.tif --output=slope.tif --variant=3x3(1) --clip=0 -v
becomes--run=laplacian_filter --input=DEM.tif --output=slope.tif --variant='3x3(1)' --clip=0 -v