Skip to content

Commit e88ec77

Browse files
Coskun KilincCoskun Kilinc
authored andcommitted
fix(numbas): allow '.' in username param for SCORM route
Rails/Grape interprets '.' in a path segment as a format separator, which broke lookups for usernames containing dots (e.g. "user.name"). Add a route requirement so :username matches any non-slash characters.
1 parent a988473 commit e88ec77

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

app/api/scorm_api.rb

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,9 @@ def stream_file_from_zip(zip_path, file_path)
5252
params do
5353
requires :task_def_id, type: Integer, desc: 'Task Definition ID to get SCORM test data for'
5454
end
55-
get '/scorm/:task_def_id/:username/:auth_token/*file_path' do
55+
56+
# NOTE: allow '.' in username; without this Rails/Grape treats '.' as format.
57+
get '/scorm/:task_def_id/:username/:auth_token/*file_path', requirements: { username: /[^\/]+/ } do
5658
task_def = TaskDefinition.find(params[:task_def_id])
5759

5860
unless authorise? current_user, task_def.unit, :get_unit

0 commit comments

Comments
 (0)