pico-engine icon indicating copy to clipboard operation
pico-engine copied to clipboard

Handling of special characters in channel tags complicates use of RID as a channel tag

Open b1conrad opened this issue 2 years ago • 2 comments

When creating a channel (ctx:newChannel (called by wrangler:createChannel)) one of the parameters is an array of strings used as tags. Each tag is sanitized, to replace runs of special characters with a dash (the precise cleaning in code is here).

However, the same cleaning is not done in wrangler:channels which returns channels with given tags.

A ruleset identifier (RID) can contain periods, so if a RID is used as one of the tags, that tag will not be equal to the RID!

Workaround is to do the necessary sanitation in KRL, as in this example:

    ridAsTag = meta:rid.replace(re#[.]#g,"-")

and use ridAsTag both in creating and in querying channels. Example in context here.

The precise cleaning to be done in KRL depends on the ruleset. In this case, the RID contains periods. RIDs that don't contain periods may not need this special treatment.

b1conrad avatar Jun 23 '22 14:06 b1conrad

What to do about this?

  1. We could just document this and leave the code alone.
  2. We could modify wrangler:channels to do the equivalent cleaning in KRL.
  3. We could expose the pico-framework cleanChannelTags in the ctx library and use it in Wrangler.

b1conrad avatar Jun 23 '22 14:06 b1conrad

Also need to ensure that the tags are lowercase characters only, and RIDs allow for uppercase characters. so a more complete sanitation would be

    ridAsTag = meta:rid.replace(re#[.]#g,"-").lc()

b1conrad avatar Nov 08 '23 11:11 b1conrad