
import json

from huxley.api.serializers import UserSerializer
from huxley.utils.shortcuts import render_template


def index(request):
    user_dict = {};
    if request.user.is_authenticated():
        user_dict = UserSerializer(request.user).data

    context = {'user_json': json.dumps(user_dict)}
    return render_template(request, 'www.html', context)


import json

from huxley.api.serializers import UserSerializer
from huxley.utils.shortcuts import render_template


def index(request):
    user_dict = {};
    if request.user.is_authenticated():
        user_dict = UserSerializer(request.user).data

    context = {'user_json': json.dumps(user_dict).replace('</', '<\\/')}
    return render_template(request, 'www.html', context)

Fix XSS vulnerability in current user bootstrapping.
Fix XSS vulnerability in current user bootstrapping.

  
  import json
  
  from huxley.api.serializers import UserSerializer
  from huxley.utils.shortcuts import render_template
  
  
  def index(request):
      user_dict = {};
      if request.user.is_authenticated():
          user_dict = UserSerializer(request.user).data
  
-     context = {'user_json': json.dumps(user_dict)}
+     context = {'user_json': json.dumps(user_dict).replace('</', '<\\/')}
      return render_template(request, 'www.html', context)
  
Fix XSS vulnerability in current user bootstrapping.
## Code Before:

import json

from huxley.api.serializers import UserSerializer
from huxley.utils.shortcuts import render_template


def index(request):
    user_dict = {};
    if request.user.is_authenticated():
        user_dict = UserSerializer(request.user).data

    context = {'user_json': json.dumps(user_dict)}
    return render_template(request, 'www.html', context)

## Instruction:
Fix XSS vulnerability in current user bootstrapping.
## Code After:

import json

from huxley.api.serializers import UserSerializer
from huxley.utils.shortcuts import render_template


def index(request):
    user_dict = {};
    if request.user.is_authenticated():
        user_dict = UserSerializer(request.user).data

    context = {'user_json': json.dumps(user_dict).replace('</', '<\\/')}
    return render_template(request, 'www.html', context)
