66from django .db .models import TextField
77from django .db .models import Value
88from django .http import HttpResponseNotFound
9+ from django .utils .html import escape
910from django .utils .translation import gettext_lazy as _
1011from django .views .decorators .cache import cache_page
1112from kolibri_content .constants .schema_versions import MIN_CONTENT_SCHEMA_VERSION
@@ -75,9 +76,7 @@ def get_public_channel_list(request, version):
7576 try :
7677 channel_list = _get_channel_list (version , request .query_params )
7778 except LookupError :
78- return HttpResponseNotFound (
79- _ ("Api endpoint {} is not available" ).format (version )
80- )
79+ return HttpResponseNotFound (_ ("API version is unavailable" ))
8180 return Response (PublicChannelSerializer (channel_list , many = True ).data )
8281
8382
@@ -92,12 +91,10 @@ def get_public_channel_lookup(request, version, identifier):
9291 identifier = identifier .strip ().replace ("-" , "" ),
9392 )
9493 except LookupError :
95- return HttpResponseNotFound (
96- _ ("Api endpoint {} is not available" ).format (version )
97- )
94+ return HttpResponseNotFound (_ ("API version is unavailable" ))
9895 if not channel_list .exists ():
9996 return HttpResponseNotFound (
100- _ ("No channel matching {} found" ).format (identifier )
97+ _ ("No channel matching {} found" ).format (escape ( identifier ) )
10198 )
10299 return Response (PublicChannelSerializer (channel_list , many = True ).data )
103100
@@ -108,7 +105,9 @@ def get_channel_name_by_id(request, channel_id):
108105 """ Endpoint: /public/channels/<channel_id> """
109106 channel = Channel .objects .filter (pk = channel_id ).first ()
110107 if not channel :
111- return HttpResponseNotFound ("Channel with id {} not found" .format (channel_id ))
108+ return HttpResponseNotFound (
109+ "Channel with id {} not found" .format (escape (channel_id ))
110+ )
112111 channel_info = {
113112 "name" : channel .name ,
114113 "description" : channel .description ,
0 commit comments