nginxinc / crossplane

Quick and reliable way to convert NGINX configurations into JSON and back.
Apache License 2.0
717 stars 86 forks source link

Fix string handling when there are quotes #41

Closed lucacome closed 6 years ago

lucacome commented 6 years ago

Handle tokens with quotes inside.

aluttik commented 6 years ago

There is no "param" syntax as far as nginx is concerned. The = character is not special in any way.

The solution is more simple than that: quotes should only be special characters when either A) they come right after a "boundary" character like whitespace, {, ;, or } or B) when they're closing a quotation. Otherwise quotes should just be read as a regular character and not cause a new token.

For example, nginx will accept this config as well despite it not having = characters:

events {}
http {
    #sub_filter API_PREFIX="/api" API_PREFIX="/nginx-api";
    sub_filter API_PREFIX"/api" API_PREFIX"/nginx-api";
}
aluttik commented 6 years ago

great work! :dash: