Re: Encoding Arrays with File Paths

2025-02-18 Thread Monte Goulding via use-livecode
Ah ok so just checked the docs on the array encode version added in LC 7 and 
found:
```
If present, and >= "7.0" then the array is encoded in such a way as to preserve 
unicode in keys and values, as well as NUL chars in keys and values
```

So try `arrayEncode(array, “7.0")`

> On 19 Feb 2025, at 10:18 AM, Bob Sneidar via use-livecode 
>  wrote:
> 
> The structure looks like the following:
> 
> Sly File Agent API
>   Structure of payload sent
> 
>  [0] 
> [profile] 
>  [n] 
> [data] 
> [datemodified] 
> [extpath] 
> [filecategory] 
> [fileid] 
> [filename]  database when data is returned>
> [filepath]  this>
> [operation] 
> [saveaction] 
> [version]  data is returned>
>  [n+1]…
> 
> The problem is definitely the binary data stored in the [n] [“data”] key. If 
> I immediately decrypt the data in the key on the MacOS the data is correct. 
> But when I decrypt the exact same data on the Windows OS I get a bad decrypt 
> error. 
> 
> So to be perfectly clear, I create the above array, I iterate through each 
> key from 1 to n, encrypting and overwriting the information in the [“data”] 
> key. I then arrayEncode the entire array, then base64encode everythign before 
> transmitting it over the wire. 
> 
> I reverse the process on the receiving side. It seems to work if I send 
> non-binary data in the [“data”] key but if the data is binary, it fails. I do 
> not think arrayEncode / decode likes to work with binary data. 
> 
> Bob S
> 
> 
>> On Feb 18, 2025, at 2:45 PM, Monte Goulding via use-livecode 
>>  wrote:
>> 
>> 
>> 
>>> On 19 Feb 2025, at 9:39 AM, Bob Sneidar via use-livecode 
>>>  wrote:
>>> 
>>> but one key is the binary file data of a file that has been encrypted using 
>>> LC’s built in library.
>> 
>> Are you using this as the key or element value? I think keys are always 
>> treated as text. It has been quite one time since I’ve been poking the 
>> engine in a meaningful way though so I might be forgetting that.
>> 
>> Cheers
>> 
>> Monte
>> ___
>> use-livecode mailing list
>> use-livecode@lists.runrev.com
>> Please visit this url to subscribe, unsubscribe and manage your subscription 
>> preferences:
>> http://lists.runrev.com/mailman/listinfo/use-livecode
> 
> ___
> use-livecode mailing list
> use-livecode@lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your subscription 
> preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode

___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode


Re: Encoding Arrays with File Paths

2025-02-18 Thread Monte Goulding via use-livecode
Hi Bob

I strongly suspect a mis-diagnosis here. If you have your paths in an array 
then do `put arrayDecode(arrayEncode(myArray)) into myArray` do you still see a 
problem? If you do please report a bug as there is a lot of code that relies on 
arrayEncode/decode round tripping with no issues.

Cheers

Monte

> On 19 Feb 2025, at 8:28 AM, Bob Sneidar via use-livecode 
>  wrote:
> 
> Hi all. 
> 
> I think I have uncovered an issue with encoding / decoding arrays where some 
> array elements are file paths. I’m thinking that the forweard slashes are 
> interfering with the decoding process. I think this because the arrayEncoded 
> data has the actual paths still intact in the data stream. 
> 
> I can work around this by base64encoding / decoding any elements with file 
> paths, but I want to make sure that the array encoding process does in fact 
> have issues with certain characters, and if it does what are those 
> characters? Is there a list of them? Can I delimit them? 
> 
> Bob S
> 
> ___
> use-livecode mailing list
> use-livecode@lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your subscription 
> preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode


___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode


Re: Encoding Arrays with File Paths

2025-02-18 Thread Bob Sneidar via use-livecode
Okay I don’t think I am having an issue with arrayEncode. I think I am having 
an issue where arrayEncoding with MacOS is failing to arrayDecode in Windows 
and vis versa.

Bob S
 

> On Feb 18, 2025, at 1:28 PM, Bob Sneidar via use-livecode 
>  wrote:
> 
> Hi all. 
> 
> I think I have uncovered an issue with encoding / decoding arrays where some 
> array elements are file paths. I’m thinking that the forweard slashes are 
> interfering with the decoding process. I think this because the arrayEncoded 
> data has the actual paths still intact in the data stream. 
> 
> I can work around this by base64encoding / decoding any elements with file 
> paths, but I want to make sure that the array encoding process does in fact 
> have issues with certain characters, and if it does what are those 
> characters? Is there a list of them? Can I delimit them? 
> 
> Bob S
> 
> ___
> use-livecode mailing list
> use-livecode@lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your subscription 
> preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode

___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode


Re: Encoding Arrays with File Paths

2025-02-18 Thread Bob Sneidar via use-livecode
Ahah! 

Okay I can do that, but I also determined that if I base64encode the encrypted 
data before putting it into the [n] [“data”] key then reverse on the other end, 
it works as well. Same idea, different technique. 

Bob S


> On Feb 18, 2025, at 3:29 PM, Monte Goulding via use-livecode 
>  wrote:
> 
> Ah ok so just checked the docs on the array encode version added in LC 7 and 
> found:
> ```
> If present, and >= "7.0" then the array is encoded in such a way as to 
> preserve unicode in keys and values, as well as NUL chars in keys and values
> ```
> 
> So try `arrayEncode(array, “7.0")`
> 
>> On 19 Feb 2025, at 10:18 AM, Bob Sneidar via use-livecode 
>>  wrote:
>> 
>> The structure looks like the following:
>> 
>> Sly File Agent API
>>  Structure of payload sent
>> 
>> [0] 
>>[profile] 
>> [n] 
>>[data] 
>>[datemodified] 
>>[extpath] 
>>[filecategory] 
>>[fileid] 
>>[filename] > database when data is returned>
>>[filepath] > this>
>>[operation] 
>>[saveaction] 
>>[version] > data is returned>
>> [n+1]…
>> 
>> The problem is definitely the binary data stored in the [n] [“data”] key. If 
>> I immediately decrypt the data in the key on the MacOS the data is correct. 
>> But when I decrypt the exact same data on the Windows OS I get a bad decrypt 
>> error. 
>> 
>> So to be perfectly clear, I create the above array, I iterate through each 
>> key from 1 to n, encrypting and overwriting the information in the [“data”] 
>> key. I then arrayEncode the entire array, then base64encode everythign 
>> before transmitting it over the wire. 
>> 
>> I reverse the process on the receiving side. It seems to work if I send 
>> non-binary data in the [“data”] key but if the data is binary, it fails. I 
>> do not think arrayEncode / decode likes to work with binary data. 
>> 
>> Bob S
>> 
>> 
>>> On Feb 18, 2025, at 2:45 PM, Monte Goulding via use-livecode 
>>>  wrote:
>>> 
>>> 
>>> 
 On 19 Feb 2025, at 9:39 AM, Bob Sneidar via use-livecode 
  wrote:
 
 but one key is the binary file data of a file that has been encrypted 
 using LC’s built in library.
>>> 
>>> Are you using this as the key or element value? I think keys are always 
>>> treated as text. It has been quite one time since I’ve been poking the 
>>> engine in a meaningful way though so I might be forgetting that.
>>> 
>>> Cheers
>>> 
>>> Monte
>>> ___
>>> use-livecode mailing list
>>> use-livecode@lists.runrev.com
>>> Please visit this url to subscribe, unsubscribe and manage your 
>>> subscription preferences:
>>> http://lists.runrev.com/mailman/listinfo/use-livecode
>> 
>> ___
>> use-livecode mailing list
>> use-livecode@lists.runrev.com
>> Please visit this url to subscribe, unsubscribe and manage your subscription 
>> preferences:
>> http://lists.runrev.com/mailman/listinfo/use-livecode
> 
> ___
> use-livecode mailing list
> use-livecode@lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your subscription 
> preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode

___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode


Re: Encoding Arrays with File Paths

2025-02-18 Thread Bob Sneidar via use-livecode
Thanks Monte. 

Here is what I am doing: 

I have a numbered array. Element 0 has a key called operation which simply has 
a string with one of several possible values. 

Then I have elements 1 to n with a number of different elements, most are 
simple strings, but one key is the binary file data of a file that has been 
encrypted using LC’s built in library. 

Before I send the file over a socket, I base64encode it. I verified that the 
base64encoded string on the receiving end matches the one on the sending end. 

Curiously however I cannot even arrayDecode right after I arrayEncode and have 
it work so something is getting corrupted by the array encode / decode 
functions. 

I think what I will have to do is start commenting out different elements to 
see which one is the issue. It may well be the file data. 

Bob S


> On Feb 18, 2025, at 2:15 PM, Monte Goulding via use-livecode 
>  wrote:
> 
> 
> 
>> On 19 Feb 2025, at 9:09 AM, Bob Sneidar via use-livecode 
>>  wrote:
>> 
>> Okay I don’t think I am having an issue with arrayEncode. I think I am 
>> having an issue where arrayEncoding with MacOS is failing to arrayDecode in 
>> Windows and vis versa.
> 
> The result of arrayEncode is a binary string so you need to ensure it is not 
> treated as text either writing it out or reading it in. For example if 
> reading or writing to disk use a `binfile:` url or binary mode on open file.
> 
> Cheers
> 
> Monte
> ___
> use-livecode mailing list
> use-livecode@lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your subscription 
> preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode

___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode


Re: Encoding Arrays with File Paths

2025-02-18 Thread Monte Goulding via use-livecode


> On 19 Feb 2025, at 9:09 AM, Bob Sneidar via use-livecode 
>  wrote:
> 
> Okay I don’t think I am having an issue with arrayEncode. I think I am having 
> an issue where arrayEncoding with MacOS is failing to arrayDecode in Windows 
> and vis versa.

The result of arrayEncode is a binary string so you need to ensure it is not 
treated as text either writing it out or reading it in. For example if reading 
or writing to disk use a `binfile:` url or binary mode on open file.

Cheers

Monte
___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode


Re: Encoding Arrays with File Paths

2025-02-18 Thread Monte Goulding via use-livecode


> On 19 Feb 2025, at 9:39 AM, Bob Sneidar via use-livecode 
>  wrote:
> 
>  but one key is the binary file data of a file that has been encrypted using 
> LC’s built in library. 

Are you using this as the key or element value? I think keys are always treated 
as text. It has been quite one time since I’ve been poking the engine in a 
meaningful way though so I might be forgetting that.

Cheers

Monte
___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode


Re: Encoding Arrays with File Paths

2025-02-18 Thread Bob Sneidar via use-livecode
The structure looks like the following:

Sly File Agent API
   Structure of payload sent

  [0] 
 [profile] 
  [n] 
 [data] 
 [datemodified] 
 [extpath] 
 [filecategory] 
 [fileid] 
 [filename] 
 [filepath] 
 [operation] 
 [saveaction] 
 [version] 
  [n+1]…

The problem is definitely the binary data stored in the [n] [“data”] key. If I 
immediately decrypt the data in the key on the MacOS the data is correct. But 
when I decrypt the exact same data on the Windows OS I get a bad decrypt error. 

So to be perfectly clear, I create the above array, I iterate through each key 
from 1 to n, encrypting and overwriting the information in the [“data”] key. I 
then arrayEncode the entire array, then base64encode everythign before 
transmitting it over the wire. 

I reverse the process on the receiving side. It seems to work if I send 
non-binary data in the [“data”] key but if the data is binary, it fails. I do 
not think arrayEncode / decode likes to work with binary data. 

Bob S


> On Feb 18, 2025, at 2:45 PM, Monte Goulding via use-livecode 
>  wrote:
> 
> 
> 
>> On 19 Feb 2025, at 9:39 AM, Bob Sneidar via use-livecode 
>>  wrote:
>> 
>> but one key is the binary file data of a file that has been encrypted using 
>> LC’s built in library. 
> 
> Are you using this as the key or element value? I think keys are always 
> treated as text. It has been quite one time since I’ve been poking the engine 
> in a meaningful way though so I might be forgetting that.
> 
> Cheers
> 
> Monte
> ___
> use-livecode mailing list
> use-livecode@lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your subscription 
> preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode

___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode


Encoding Arrays with File Paths

2025-02-18 Thread Bob Sneidar via use-livecode
Hi all. 

I think I have uncovered an issue with encoding / decoding arrays where some 
array elements are file paths. I’m thinking that the forweard slashes are 
interfering with the decoding process. I think this because the arrayEncoded 
data has the actual paths still intact in the data stream. 

I can work around this by base64encoding / decoding any elements with file 
paths, but I want to make sure that the array encoding process does in fact 
have issues with certain characters, and if it does what are those characters? 
Is there a list of them? Can I delimit them? 

Bob S

___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode