                  if autoescape and not safe_input:
                      lead, trail = escape(lead), escape(trail)
                      url, trimmed = escape(url), escape(trimmed)
                  middle = '<a href="%s"%s>%s</a>' % (url, nofollow_attr, trimmed)
                  words[i] = mark_safe('%s%s%s' % (lead, middle, trail))
              else:
                  if safe_input:
                      words[i] = mark_safe(word)
                  elif autoescape:
                      words[i] = escape(word)
 
</s> remove                 if autoescape and not safe_input:
                    lead, trail = escape(lead), escape(trail)
                    url, trimmed = escape(url), escape(trimmed)
 </s> add                 lead, trail = conditional_escape(lead), conditional_escape(trail)
                url, trimmed = conditional_escape(url), conditional_escape(trimmed) </s> remove                 if safe_input:
                    words[i] = mark_safe(word)
                elif autoescape:
                    words[i] = escape(word)
        elif safe_input:
            words[i] = mark_safe(word)
        elif autoescape:
            words[i] = escape(word)
    return ''.join(words)
 </s> add                 words[i] = conditional_escape(word)
        else:
            words[i] = conditional_escape(word)
    return mark_safe(''.join(words)) </s> remove         rendered = template.render(Context({'content': '"http://example.com"'}))
        assert rendered == '"<a href="http://example.com" rel="nofollow">http://example.com</a>"'
 </s> add         rendered = template.render(Context({'content': '<b> "http://example.com" </b>'}))
        assert rendered == '<b> "<a href="http://example.com" rel="nofollow">http://example.com</a>" </b>'
                words[i] = '%s%s%s' % (lead, middle, trail)
                  if autoescape and not safe_input:
                      lead, trail = escape(lead), escape(trail)
                      url, trimmed = escape(url), escape(trimmed)
                  middle = '<a href="%s"%s>%s</a>' % (url, nofollow_attr, trimmed)
                words[i] = '%s%s%s' % (lead, middle, trail)
              else:
                  if safe_input:
                      words[i] = mark_safe(word)
                  elif autoescape:
                      words[i] = escape(word)
keep keep keep keep replace keep keep keep keep keep
 Fix XSS caused by disabled autoescaping in the default DRF Browsable API view templates (#6330)

* Add test that verifies that HTML is correctly escaped in Browsable API views

* Fix `urlize_quoted_links` tag to avoid double escaping in autoescape mode

* Fix XSS in default DRF Browsable API template by re-enabling autoescape 
rest_framework/templatetags/rest_framework.py