Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Crash on multiline strings #17

Open
tkafka opened this issue Mar 14, 2021 · 0 comments
Open

Crash on multiline strings #17

tkafka opened this issue Mar 14, 2021 · 0 comments

Comments

@tkafka
Copy link

tkafka commented Mar 14, 2021

When parsing a multiline string like this

	add_header X-Content-Security-Policy "default-src 'self'; \
	script-src 'self' https://ssl.google-analytics.com; \
	img-src 'self' https://ssl.google-analytics.com";

nginxbeautifier crashes with a following error:

/opt/homebrew/lib/node_modules/nginxbeautifier/nginxbeautifier.js:142
        return input.match(catchRegex)[1];
                                      ^

TypeError: Cannot read property '1' of null
    at extractTextBySeperator (/opt/homebrew/lib/node_modules/nginxbeautifier/nginxbeautifier.js:142:39)
    at extractAllPossibleText (/opt/homebrew/lib/node_modules/nginxbeautifier/nginxbeautifier.js:164:29)
    at strip_line (/opt/homebrew/lib/node_modules/nginxbeautifier/nginxbeautifier.js:193:35)
    at Object.clean_lines (/opt/homebrew/lib/node_modules/nginxbeautifier/nginxbeautifier.js:217:49)
    at Object.<anonymous> (/opt/homebrew/lib/node_modules/nginxbeautifier/index.js:235:38)
    at Module._compile (node:internal/modules/cjs/loader:1092:14)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1121:10)
    at Module.load (node:internal/modules/cjs/loader:972:32)
    at Function.Module._load (node:internal/modules/cjs/loader:813:14)
    at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:76:12)

The workaround is to concatenate the string onto a long line:

	add_header X-Content-Security-Policy "default-src 'self'; script-src 'self' https://ssl.google-analytics.com;  img-src 'self' https://ssl.google-analytics.com";
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant