Message sanitization is now configurable on a per-story level.

Story configuration includes a filter for specifying sanitization rules: dis/allowing capitals and non-ASCII characters.
The agent does not care about these rules, and just sends its message. If more limiting rules becomes available, the agent might want to adjust its message parsing according to the active audience.
This commit is contained in:
Fang 2017-05-09 21:43:42 +02:00
parent 165b94872e
commit 076f3a0ac4
3 changed files with 67 additions and 25 deletions

View File

@ -71,6 +71,7 @@
{$create p/security q/knot r/cord} ::< create circle
{$delete p/knot q/(unit cord)} ::< delete circle
{$depict p/knot q/cord} ::< change description
{$filter p/knot q/? r/?} ::< change message rules
{$invite p/knot q/(set ship)} ::< give permission
{$banish p/knot q/(set ship)} ::< deny permission
{$source p/knot q/(set partner)} ::< add source
@ -578,6 +579,12 @@
(cold %brown (jest %mailbox))
==
::
++ lobe ::< y/n loob
;~ pose
(cold %& ;~(pose (jest 'y') (jest '&')))
(cold %| ;~(pose (jest 'n') (jest '|')))
==
::
++ message ::< exp, lin or url msg
;~ pose
;~(plug (cold %eval hax) expr)
@ -592,7 +599,7 @@
==
::
++ nick (cook crip (stun [1 14] low)) ::< nickname
++ text (cook crip (plus (shim ' ' '~'))) ::< bullets separating
++ text (cook crip (plus next)) ::< bullets separating
++ glyph (mask "/\\\{(<!?{(zing glyphs)}") ::< circle postfix
++ setting ::< setting flag
%- perk :~
@ -627,6 +634,8 @@
::
;~((glue ace) (perk %depict ~) cire qut)
::
;~((glue ace) (perk %filter ~) cire lobe lobe)
::
;~((glue ace) (perk %invite ~) cire shiz)
::
;~((glue ace) (perk %banish ~) cire shiz)
@ -774,6 +783,7 @@
$create (create +.job)
$delete (delete +.job)
$depict (depict +.job)
$filter (filter +.job)
$invite (invite +.job)
$banish (banish +.job)
$source (source +.job)
@ -937,6 +947,11 @@
^+ ..sh-work
(sh-act %permit nom & sis)
::
++ filter
|= {nom/knot cus/? utf/?}
^+ ..sh-work
(sh-act %filter nom cus utf)
::
++ banish ::< %banish
::> banish {sis} from our circle {nom}.
::

View File

@ -302,6 +302,7 @@
$create (action-create +.act)
$source (action-source +.act)
$depict (action-depict +.act)
$filter (action-filter +.act)
$permit (action-permit +.act)
$delete (action-delete +.act)
$enlist (action-enlist +.act)
@ -342,6 +343,7 @@
%+ ta-config nom
:* [[%& our.bol nom] ~ ~]
des
[| |]
[typ ~]
[[our.bol ~ ~] [our.bol ~ ~]]
==
@ -370,6 +372,16 @@
=. cap.shape.soy des
(ta-config nom shape.soy)
::
++ action-filter ::< change message rules
::> replaces the story's current filter with the
::> specified one.
::
|= {nom/knot fit/filter}
^+ ..ta-action
%- (affect nom) |= {sor/_so soy/story}
=. fit.shape.soy fit
(ta-config nom shape.soy)
::
++ action-permit ::< invite/banish
::> invite to/banish from story {nom} all {sis}.
::
@ -754,32 +766,10 @@
?~ tos +>
$(tos t.tos, +> (ta-consume pub aut i.tos))
::
++ ta-sane ::< sanitize
::> sanitize %lin speech, enforce lowercase and no special characters.
::TODO make configurable per-circle.
::
|= tot/thought
^- thought
?. ?=({$lin *} sep.sam.tot) tot
%_ tot
msg.sep.sam
%- crip
%+ scag 64
%- tufa
%+ turn (tuba (trip msg.sep.sam.tot))
|= a/@c
?: &((gte a 'A') (lte a 'Z'))
(add a 32)
?: |((lth a 32) (gth a 126))
`@`'?'
a
==
::
++ ta-consume ::< to each audience
::> conducts thought {tot} to each partner in its audience.
::
|= {pub/? aut/ship tot/thought}
=. tot (ta-sane tot)
=+ aud=(~(tap by aud.tot))
|- ^+ +>.^$
?~ aud +>.^$
@ -1401,6 +1391,35 @@
::> arms for adding to this story's messages.
::+|
::
++ so-sane ::< sanitize
::> sanitize %lin speech according to our settings.
::
|= tot/thought
^- thought
?. ?=({$lin *} sep.sam.tot) tot
%_ tot
msg.sep.sam
%- crip
%- tufa
%+ turn (tuba (trip msg.sep.sam.tot))
|= a/@c
:: always replace control characters.
?: |((lth a 32) =(a `@c`127))
`@`'?'
:: if desired, remove uppercasing.
?: ?& !cus.fit.shape
(gte a 'A')
(lte a 'Z')
==
(add a 32)
:: if desired, replace non-ascii characters.
?: ?& !utf.fit.shape
(gth a 127)
==
`@`'?'
a
==
::
++ so-refresh ::< update to listeners
::> called when messages get added or changed.
::> calculates the changes and sends them to all
@ -1451,8 +1470,10 @@
::
|= gam/telegram
^+ +>
?. (so-admire aut.gam) ::< write permissions
+>.$
:: check for write permissions.
?. (so-admire aut.gam) +>.$
:: clean up the message to conform to our rules.
=. tot.gam (so-sane tot.gam)
=. aud.tot.gam
::> if we are in the audience, mark as received.
=+ ole=(~(get by aud.tot.gam) [%& our.bol nom])

View File

@ -14,6 +14,7 @@
{$create nom/knot des/cord sec/security} ::< create circle
{$delete nom/knot ano/(unit cord)} ::< delete + announce
{$depict nom/knot des/cord} ::< change description
{$filter nom/knot fit/filter} ::< change message rules
{$permit nom/knot inv/? sis/(set ship)} ::< invite/banish
{$source nom/knot sub/? src/(set partner)} ::< un/sub to/from src
{$enlist nom/knot fed/? sis/(set ship)} ::< dis/allow federation
@ -84,9 +85,14 @@
++ config ::> circle config
$: src/(set partner) ::< pulls from
cap/cord ::< description
fit/filter ::< message rules
con/control ::< restrictions
fed/federal ::< federators
== ::
++ filter ::> content filters
$: cus/? ::< dis/allow capitals
utf/? ::< dis/allow non-ascii
== ::
++ control {sec/security ses/(set ship)} ::< access control
++ security ::> security kind
$? $black ::< channel, blacklist