lr =: 3 : '5!:5 <''y'''

lr is pretty cool:

   lr 1 10 $ +: 5 * i:10
_100+10*i.1 10

with sparse arrays though, it does something weird and not obviously necessary:

   lr $. 0 0 3 0 5
3 5 (2 4)}1$.(,5);(,0);0+-~2

   lr 10 + $. 0 0 3 0 5 0 
13 15 (2 4)}1$.(,6);(,0);10+-~2

The weird part is the little piece at the end.  x+-~2 is x + 2 - 2  .... or x.

it also seems unnecessary for undoing?  
   $. inv ". '13 15 (2 4)}1$.(,6);(,0);10'
10 10 13 10 15 10

is this a bug in lr.  For purposes of JON, i can add a check that allows 
passive but rejects evoke, and it would only slow down parsing when ~ exists as 
a standalone symbol, and I guess that seems necessary since this is not a bug, 
but rather floating point adjustment:

   lr 10.2 + $. 0 0 3 0 5 0 
13.199999999999999 15.199999999999999 (2 
4)}1$.(,6);(,0);10.199999999999999+-~2.1



----- Original Message -----
From: Pascal Jasmin <godspiral2...@yahoo.ca>
To: "programm...@jsoftware.com" <programm...@jsoftware.com>
Cc: 
Sent: Wednesday, February 26, 2014 4:58:31 PM
Subject: Re: [Jprogramming] introducing JON alternative to JSON

Thank you Raul,

I've updated safe1 and safe2 to prevent arbitrary names that start with aLj... 
apply was the problem rather than u: I hope.

safe1 =: '''_0123456789+*-<>|;,#{}()[]'
safe2 =: 'u:';'x:';'}.';'}:';'" ';'":';'! ';'$ ';'= ';'^ 
';'^.';'a.';'a:';'L.';'L:';'j.';'i.';'i:'



----- Original Message -----
From: Raul Miller <rauldmil...@gmail.com>
To: Programming forum <programm...@jsoftware.com>
Cc: 
Sent: Wednesday, February 26, 2014 4:05:13 PM
Subject: Re: [Jprogramming] introducing JON alternative to JSON

On Wed, Feb 26, 2014 at 1:45 PM, Pascal Jasmin <godspiral2...@yahoo.ca> wrote:
> My big question though is have I overlooked any potential unsafe code that 
> could be run with doSafe?

Yes.

Here's an example:

   exploit=: smoutput@3:
   doSafe '(u: ',(":u:inv 5!:5 <'exploit'),') apply 0'

3

Of course, there's not too much damage that a person could do with the
number 3, but hopefully the pattern is obvious.

Thanks,

-- 
Raul
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm


----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to