moodle-tool_trigger icon indicating copy to clipboard operation
moodle-tool_trigger copied to clipboard

Make URL encode of variables explict per instance

Open mattporritt opened this issue 6 years ago • 2 comments

Current all HTTP Post variables are URL encoded, this is not always helpful. Sometimes we don't want to URL encode values, and sometimes we only want to encode some values.

I suggest making a prefix on a value to indicate if it should be url encoded. So: {urlencode:username} will be encoded but {username} won't be

mattporritt avatar May 25 '18 03:05 mattporritt

The code that does the {placeholder} replacement stuff is in classes/helper/datafield_manager.php

Right now it finds placeholders by searching for the regex /\{([-_A-Za-z0-9]+)\}/u. You'll need to add : to that, and maybe also capture the "function" part before the : separately. So something like something like /\{(?:(?P<func>[_A-Za-z0-9]+):)?(?P<datafield>[-_A-Za-z0-9]+)\}/u.

agwells avatar May 25 '18 04:05 agwells

As discussed on chat, it might also be a good idea to change the syntax from {placeholder} to %placeholder% or #placeholder#, in order to reduce the conflict with JSON syntax. Particularly if we're going to be adding colons inside the {}. Although I suppose we could use something else instead, like | or even just a space: {urlencode user_username}.

agwells avatar May 25 '18 04:05 agwells