Skip to content

Commit 9a9ae86

Browse files
committed
add template for files match pattern
fixes #104
1 parent ee6cd75 commit 9a9ae86

File tree

6 files changed

+69
-4
lines changed

6 files changed

+69
-4
lines changed

bin/build/build.sh

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,8 @@ create_htaccess() {
102102
insert_line "" "$file"
103103
insert_file_comment_out "src/web_performance/filename-based_cache_busting.conf" "$file"
104104

105+
apply_pattern "$file"
106+
105107
}
106108

107109
create_htaccess_fixture() {
@@ -186,6 +188,8 @@ create_htaccess_fixture() {
186188
insert_line "" "$file"
187189
insert_file "src/web_performance/filename-based_cache_busting.conf" "$file"
188190

191+
apply_pattern "$file"
192+
189193
}
190194

191195
insert_line() {
@@ -215,6 +219,15 @@ insert_space() {
215219
printf '%0.s ' $(seq 1 $difference)
216220
}
217221

222+
apply_pattern() {
223+
sed -e "s/%FilesMatchPattern%/$( \
224+
cat "src/files_match_pattern" | \
225+
sed '/^#/d' | \
226+
tr -s '[:space:]' '|' | \
227+
sed 's/|$//' \
228+
)/g" --in-place "$1"
229+
}
230+
218231
print_error() {
219232
# Print output in red
220233
printf "\e[0;31m [✖] $1 $2\e[0m\n"

src/files_match_pattern

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
# List of extensions used for common FilesMatch directives:
2+
# * internet_explorer/x-ua-compatible.conf
3+
# * security/content-security-policy.conf
4+
# * security/x-frame-option.conf
5+
# * security/x-xss-protection.conf
6+
appcache
7+
atom
8+
bbaw
9+
bmp
10+
crx
11+
css
12+
cur
13+
eot
14+
f4[abpv]
15+
flv
16+
geojson
17+
gif
18+
htc
19+
ic[os]
20+
jpe?g
21+
m?js
22+
json(ld)?
23+
m4[av]
24+
manifest
25+
map
26+
markdown
27+
md
28+
mp4
29+
oex
30+
og[agv]
31+
opus
32+
otf
33+
pdf
34+
png
35+
rdf
36+
rss
37+
safariextz
38+
svgz?
39+
swf
40+
topojson
41+
tt[cf]
42+
txt
43+
vcard
44+
vcf
45+
vtt
46+
webapp
47+
web[mp]
48+
webmanifest
49+
woff2?
50+
xloc
51+
xml
52+
xpi

src/internet_explorer/x-ua-compatible.conf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
# the `X-UA-Compatible` response header should be send only for
2424
# HTML documents and not for the other resources.
2525

26-
<FilesMatch "\.(appcache|atom|bbaw|bmp|crx|css|cur|eot|f4[abpv]|flv|geojson|gif|htc|ico|ics|jpe?g|m?js|json(ld)?|m4[av]|manifest|map|markdown|md|mp4|oex|og[agv]|opus|otf|pdf|png|rdf|rss|safariextz|svgz?|swf|topojson|tt[cf]|txt|vcard|vcf|vtt|webapp|web[mp]|webmanifest|woff2?|xloc|xml|xpi)$">
26+
<FilesMatch "\.(%FilesMatchPattern%)$">
2727
Header unset X-UA-Compatible
2828
</FilesMatch>
2929

src/security/content-security-policy.conf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
# the `Content-Security-Policy` response header should be send
2828
# only for HTML documents and not for the other resources.
2929

30-
<FilesMatch "\.(appcache|atom|bbaw|bmp|crx|css|cur|eot|f4[abpv]|flv|geojson|gif|htc|ico|ics|jpe?g|m?js|json(ld)?|m4[av]|manifest|map|markdown|md|mp4|oex|og[agv]|opus|otf|pdf|png|rdf|rss|safariextz|svgz?|swf|topojson|tt[cf]|txt|vcard|vcf|vtt|webapp|web[mp]|webmanifest|woff2?|xloc|xml|xpi)$">
30+
<FilesMatch "\.(%FilesMatchPattern%)$">
3131
Header unset Content-Security-Policy
3232
</FilesMatch>
3333

src/security/x-frame-option.conf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040
# the `X-Frame-Options` response header should be send only for
4141
# HTML documents and not for the other resources.
4242

43-
<FilesMatch "\.(appcache|atom|bbaw|bmp|crx|css|cur|eot|f4[abpv]|flv|geojson|gif|htc|ico|ics|jpe?g|m?js|json(ld)?|m4[av]|manifest|map|markdown|md|mp4|oex|og[agv]|opus|otf|pdf|png|rdf|rss|safariextz|svgz?|swf|topojson|tt[cf]|txt|vcard|vcf|vtt|webapp|web[mp]|webmanifest|woff2?|xloc|xml|xpi)$">
43+
<FilesMatch "\.(%FilesMatchPattern%)$">
4444
Header unset X-Frame-Options
4545
</FilesMatch>
4646

src/security/x-xss-protection.conf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@
4343
# the `X-XSS-Protection` response header should be send only for
4444
# HTML documents and not for the other resources.
4545

46-
<FilesMatch "\.(appcache|atom|bbaw|bmp|crx|css|cur|eot|f4[abpv]|flv|geojson|gif|htc|ico|ics|jpe?g|m?js|json(ld)?|m4[av]|manifest|map|markdown|md|mp4|oex|og[agv]|opus|otf|pdf|png|rdf|rss|safariextz|svgz?|swf|topojson|tt[cf]|txt|vcard|vcf|vtt|webapp|web[mp]|webmanifest|woff2?|xloc|xml|xpi)$">
46+
<FilesMatch "\.(%FilesMatchPattern%)$">
4747
Header unset X-XSS-Protection
4848
</FilesMatch>
4949

0 commit comments

Comments
 (0)