This project has moved and is read-only. For the latest updates, please go here.
1
Vote

RegEx bug in RteApiSite.js

description

In RteApiSite.js there is code in function Site_SetValue:
if ( (name.match(/^.*\.interactions\..*/) != null) ||
    ( name.match(/^.*\.score\..*/) != null) || 
    ( name.match(/^.*\.completion_status\..*/) != null) || 
    ( name.match(/^.*\.exit\..*/) != null) || 
    ( name.match(/^.*\.success_status\..*/) != null) || 
    ( name.match(/^.*\.progress_measure\..*/) != null) )
{
    this.ClearValidNavigationCommands();
}
The problem is that this regex will catch strings like:
  • cmi.completion_status.bar
  • cmi.exit.foo
But these are not commands defined in the SCORM standard.

The SCORM standard defines commands like:
  • cmi.completion_status
  • cmi.exit
These commands are withnout the last dot which is mandatory in the regex definition:
name.match(/^.*\.completion_status\..*/)
With the last: \.

Therefore the if will not catch the cmi.completion_status or cmi.exit commands.

The first two commands (interactions and score) have a mandatory suffix like:
  • cmi.interactions._children
  • cmi.interactions._count
  • cmi.score._children
  • cmi.score.scaled
Therefore we can keep the mandatory dot in these cases.

The correct code should be:
if ( (name.match(/^.*\.interactions\..*/) != null) ||
    ( name.match(/^.*\.score\..*/) != null) || 
    ( name.match(/^.*\.completion_status.*/) != null) || 
    ( name.match(/^.*\.exit.*/) != null) || 
    ( name.match(/^.*\.success_status.*/) != null) || 
    ( name.match(/^.*\.progress_measure.*/) != null) )
{
    this.ClearValidNavigationCommands();
}

comments