In Ring 1.25 (GitHub) - Better TokensLib - CheckRingCode() function

34 views
Skip to first unread message

Mahmoud Fayed

unread,
Dec 9, 2025, 3:17:28 AM (10 days ago) Dec 9
to The Ring Programming Language
Hello

In Ring 1.25 (GitHub), The TokensLib is updated 

The library is updated to include the checkRingCode() function which is used for security.

Syntax:

checkRingCode(aPara) ---> 1/0 (True/False)

It is expected to be called before eval() when the input is just a Ring List.

The function does not accept code that contains Ring keywords or specific operators such as (), {}, ., ?

In other words: no statements, no function calls, no object access, and no output using the ? operator.

The function support options like safe keywords and safe operators.

Example:

load "tokenslib.ring" func main cCode = `mylist = [1,2,3,:one,:two,:three]` ? checkRingCode([:code = cCode]) // 1 (True) cCode = `? "hello world"` ? checkRingCode([:code = cCode]) // 0 (False) ? checkRingCode([:code = cCode, :safeoperators="?"]) // 1 (True) cCode = `test(1)` ? checkRingCode([:code = cCode]) // 0 (False) ? checkRingCode([:code = cCode, :safeoperators="()"]) // 1 (True) cCode = `myobj { x=10 }` ? checkRingCode([:code = cCode]) // 0 (False) ? checkRingCode([:code = cCode, :safeoperators="{}"]) // 1 (True) cCode = `see 'hi'` ? checkRingCode([:code = cCode]) // 0 (False) ? checkRingCode([:code = cCode, :safekeywords=[:see]]) // 1 (True) cCode = `see new point { x=10 }` ? checkRingCode([:code = cCode]) // 0 (False) ? checkRingCode([:code = cCode, :safeoperators="{}", :safekeywords=[:see, :new]]) // 1 (True)

The next applications and tools are updated to use the checkRingCode() function

  • Ring Notepad - Use checkRingCode() before using the settings file

  • Form Designer - Use checkRingCode() before loading the form file

  • RingPM GUI - Use checkRingCode() before using the package file

  • RingPM - Use checkRingCode() before using the package file

  • Ring2EXE - Use checkRingCode() before using the library file

  • GoldMagic800 game - Use checkRingCode() before using the level file

  • GoldMagic800 Levels Designer - Use checkRingCode() before using the level file

  • Lectures Tracker application - Use checkRingCode() before using the lectures file

Greetings,
Mahmoud
Reply all
Reply to author
Forward
0 new messages