Skip to content
This repository has been archived by the owner on Aug 26, 2022. It is now read-only.

Commit

Permalink
Merge pull request #3291 from mozilla/bug1175474
Browse files Browse the repository at this point in the history
Fix bug 1175474 - Correctly compare generated URLs with config values.
  • Loading branch information
stephaniehobson committed Jun 30, 2015
2 parents ca9da6b + 21f3b45 commit 16159f7
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 1 deletion.
26 changes: 26 additions & 0 deletions kuma/wiki/tests/test_views.py
Expand Up @@ -335,6 +335,32 @@ def test_revision_view_bleached_content(self):
ok_('<svg>' not in ct)
ok_('<a href="#">Hahaha</a>' in ct)

def test_raw_css_view(self):
"""The raw source for a document can be requested"""
self.client.login(username='admin', password='testpass')
doc = document(title='Template:CustomSampleCSS',
slug='Template:CustomSampleCSS',
save=True)
revision(
save=True,
is_approved=True,
document=doc,
content="""
/* CSS here */
body {
padding: 0;
margin: 0;
}
svg:not(:root) {
display:block;
}
""")
response = self.client.get('%s?raw=true' %
reverse('wiki.document', args=[doc.slug]))
ok_('text/css' in response['Content-Type'])


class PermissionTests(UserTestCase, WikiTestCase):
localizing_client = True
Expand Down
3 changes: 2 additions & 1 deletion kuma/wiki/views.py
Expand Up @@ -25,6 +25,7 @@
from django.http.multipartparser import MultiPartParser
from django.shortcuts import (get_object_or_404, get_list_or_404,
redirect, render)
from django.utils.http import urlunquote_plus
from django.utils.safestring import mark_safe
from django.views.decorators.http import (require_GET, require_POST,
require_http_methods, condition)
Expand Down Expand Up @@ -402,7 +403,7 @@ def _document_raw(request, doc, doc_html, rendering_params):
response = HttpResponse(doc_html)
response['X-Frame-Options'] = 'Allow'
response['X-Robots-Tag'] = 'noindex'
absolute_url = doc.get_absolute_url()
absolute_url = urlunquote_plus(doc.get_absolute_url())

if absolute_url in (config.KUMA_CUSTOM_CSS_PATH,
config.KUMA_CUSTOM_SAMPLE_CSS_PATH):
Expand Down

0 comments on commit 16159f7

Please sign in to comment.