Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Concatenate two strings in apache config

In an apache config file how can i concatenate two strings?

For example:

"hello" + "world"
// "helloworld"

Why?

One might want to do this to handle large Headers such as a Content-Security-Policy below is an example of my CSP. You can see it is nicely formatted for maintainability but when being sent in the Headers it has unwanted whitespace.

Header set Content-Security-Policy "\
;default-src\
    'self'\
;child-src\
    'self'\
;connect-src\
    'self'\
;font-src\
    'self'\
    https://*.gstatic.com\
;form-action\
    'self';\
;frame-ancestors\
    'self'\
;frame-src\
    'self'\
;img-src\
    'self'\
    https://www.google.com/s2/favicons\
    https://www.google-analytics.com\
    https://*.gstatic.com\
    https://*.googleapis.com\
;object-src\
    'none'\
;script-src\
    'self'\
    'unsafe-eval'\
    https://www.google-analytics.com\
    https://*.googleapis.com\
;style-src\
    'self'\
    'unsafe-inline'\
    https://*.googleapis.com\
;\
"
like image 724
Blowsie Avatar asked Jul 27 '18 10:07

Blowsie


1 Answers

I think you can declare variable like this : https://stackoverflow.com/a/15731921/6663198
Then, you can easily concatenate your variables

like image 57
Flyzzx Avatar answered Nov 19 '22 07:11

Flyzzx