Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Prevent generated id from becoming too long
  • Loading branch information
torinfo committed Nov 29, 2015
1 parent c5b5cc7 commit c2f381f
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
7 changes: 6 additions & 1 deletion modules/xerte/scorm1.2/xttracking_scorm1.2.js
Expand Up @@ -41,7 +41,12 @@ function makeId(page_nr, ia_nr, ia_type, ia_name)
}
if (ia_name)
{
tmpid += ':' + encodeURIComponent(ia_name.replace(/ /g, "_"));
// ia_nam can be HTML, just extract text from it
var div = $("<div>").html(ia_name);
var strippedName = div.text();
tmpid += ':' + encodeURIComponent(strippedName.replace(/ /g, "_"));
// Truncate to max 255 chars
tmpid = tmpid.substr(0,255);
}
return tmpid;
}
Expand Down
8 changes: 7 additions & 1 deletion modules/xerte/scorm2004.3rd/xttracking_scorm2004.3rd.js
Expand Up @@ -38,9 +38,15 @@ function makeId(page_nr, ia_nr, ia_type, ia_name)
tmpid += '-' + ia_type;
}
}

if (ia_name)
{
tmpid += ':' + encodeURIComponent(ia_name.replace(/ /g, "_"));
// ia_nam can be HTML, just extract text from it
var div = $("<div>").html(ia_name);
var strippedName = div.text();
tmpid += ':' + encodeURIComponent(strippedName.replace(/ /g, "_"));
// Truncate to max 255 chars, this should be 4000
tmpid = tmpid.substr(0,255);
}
return tmpid;
}
Expand Down

0 comments on commit c2f381f

Please sign in to comment.