Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
E
edx-platform
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
edx
edx-platform
Commits
e57d1a20
Commit
e57d1a20
authored
Feb 02, 2016
by
Toby Lawrence
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add leading period so we don't get partial matches on extensions.
parent
1183f6ce
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
8 additions
and
7 deletions
+8
-7
common/djangoapps/static_replace/models.py
+2
-1
common/djangoapps/static_replace/test/test_static_replace.py
+4
-2
common/lib/xmodule/xmodule/contentstore/content.py
+2
-4
No files found.
common/djangoapps/static_replace/models.py
View file @
e57d1a20
...
@@ -44,7 +44,8 @@ class AssetExcludedExtensionsConfig(ConfigurationModel):
...
@@ -44,7 +44,8 @@ class AssetExcludedExtensionsConfig(ConfigurationModel):
@classmethod
@classmethod
def
get_excluded_extensions
(
cls
):
def
get_excluded_extensions
(
cls
):
"""Gets the excluded file extensions when canonicalizing static asset paths"""
"""Gets the excluded file extensions when canonicalizing static asset paths"""
return
cls
.
current
()
.
excluded_extensions
.
split
()
add_period
=
lambda
x
:
'.'
+
x
return
map
(
add_period
,
cls
.
current
()
.
excluded_extensions
.
split
())
def
__repr__
(
self
):
def
__repr__
(
self
):
return
'<AssetExcludedExtensionsConfig(extensions={})>'
.
format
(
self
.
get_excluded_extensions
()
.
split
())
return
'<AssetExcludedExtensionsConfig(extensions={})>'
.
format
(
self
.
get_excluded_extensions
()
.
split
())
...
...
common/djangoapps/static_replace/test/test_static_replace.py
View file @
e57d1a20
...
@@ -445,6 +445,7 @@ class CanonicalContentTest(SharedModuleStoreTestCase):
...
@@ -445,6 +445,7 @@ class CanonicalContentTest(SharedModuleStoreTestCase):
)
)
@ddt.unpack
@ddt.unpack
def
test_canonical_asset_path_with_new_style_assets
(
self
,
base_url
,
start
,
expected
,
mongo_calls
):
def
test_canonical_asset_path_with_new_style_assets
(
self
,
base_url
,
start
,
expected
,
mongo_calls
):
exts
=
[
'.html'
,
'.tm'
]
prefix
=
'split'
prefix
=
'split'
encoded_base_url
=
quote_plus
(
'//'
+
base_url
)
encoded_base_url
=
quote_plus
(
'//'
+
base_url
)
c4x
=
'c4x/a/b/asset'
c4x
=
'c4x/a/b/asset'
...
@@ -473,7 +474,7 @@ class CanonicalContentTest(SharedModuleStoreTestCase):
...
@@ -473,7 +474,7 @@ class CanonicalContentTest(SharedModuleStoreTestCase):
)
)
with
check_mongo_calls
(
mongo_calls
):
with
check_mongo_calls
(
mongo_calls
):
asset_path
=
StaticContent
.
get_canonicalized_asset_path
(
self
.
courses
[
prefix
]
.
id
,
start
,
base_url
,
[
'html'
]
)
asset_path
=
StaticContent
.
get_canonicalized_asset_path
(
self
.
courses
[
prefix
]
.
id
,
start
,
base_url
,
exts
)
self
.
assertEqual
(
asset_path
,
expected
)
self
.
assertEqual
(
asset_path
,
expected
)
@ddt.data
(
@ddt.data
(
...
@@ -630,6 +631,7 @@ class CanonicalContentTest(SharedModuleStoreTestCase):
...
@@ -630,6 +631,7 @@ class CanonicalContentTest(SharedModuleStoreTestCase):
)
)
@ddt.unpack
@ddt.unpack
def
test_canonical_asset_path_with_c4x_style_assets
(
self
,
base_url
,
start
,
expected
,
mongo_calls
):
def
test_canonical_asset_path_with_c4x_style_assets
(
self
,
base_url
,
start
,
expected
,
mongo_calls
):
exts
=
[
'.html'
,
'.tm'
]
prefix
=
'old'
prefix
=
'old'
c4x_block
=
'c4x/a/b/asset'
c4x_block
=
'c4x/a/b/asset'
encoded_c4x_block
=
quote_plus
(
'/'
+
c4x_block
+
'/'
)
encoded_c4x_block
=
quote_plus
(
'/'
+
c4x_block
+
'/'
)
...
@@ -649,5 +651,5 @@ class CanonicalContentTest(SharedModuleStoreTestCase):
...
@@ -649,5 +651,5 @@ class CanonicalContentTest(SharedModuleStoreTestCase):
)
)
with
check_mongo_calls
(
mongo_calls
):
with
check_mongo_calls
(
mongo_calls
):
asset_path
=
StaticContent
.
get_canonicalized_asset_path
(
self
.
courses
[
prefix
]
.
id
,
start
,
base_url
,
[
'html'
]
)
asset_path
=
StaticContent
.
get_canonicalized_asset_path
(
self
.
courses
[
prefix
]
.
id
,
start
,
base_url
,
exts
)
self
.
assertEqual
(
asset_path
,
expected
)
self
.
assertEqual
(
asset_path
,
expected
)
common/lib/xmodule/xmodule/contentstore/content.py
View file @
e57d1a20
...
@@ -201,10 +201,8 @@ class StaticContent(object):
...
@@ -201,10 +201,8 @@ class StaticContent(object):
# See if this is an allowed file extension to serve. Some files aren't served through the
# See if this is an allowed file extension to serve. Some files aren't served through the
# CDN in order to avoid same-origin policy/CORS-related issues.
# CDN in order to avoid same-origin policy/CORS-related issues.
for
excluded_ext
in
excluded_exts
:
if
any
(
relative_path
.
lower
()
.
endswith
(
excluded_ext
.
lower
())
for
excluded_ext
in
excluded_exts
):
if
relative_path
.
lower
()
.
endswith
(
excluded_ext
.
lower
()):
serve_from_cdn
=
False
serve_from_cdn
=
False
break
# Update any query parameter values that have asset paths in them. This is for assets that
# Update any query parameter values that have asset paths in them. This is for assets that
# require their own after-the-fact values, like a Flash file that needs the path of a config
# require their own after-the-fact values, like a Flash file that needs the path of a config
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment