Skip to content

*_by_lua should unescape the newline "\n" #85

Open
@Triple-Z

Description

@Triple-Z

Describe the bug

When I try to use the crossplane, just using parser to read a standard NGINX config file and then using the build to convert it back. However, I found that the *_by_lua directives' newline was replaced by literal \n. So I think this is a bug for that.

To Reproduce
Steps to reproduce the behavior:

  1. Create an nginx config file with the following content:
user nobody;
worker_processes 1;

events {
  worker_connections 10240;
}

http {
    
    sendfile on;
    tcp_nopush on;
    tcp_nodelay on;

    server {
        listen      80;
        server_name test.triplez.space 1.2.3.4;
        rewrite_by_lua '
            print("rewrite phase")
        ';
        
        location / {
            access_by_lua 'print("access phase")';
            default_type 'text/plain';
            return 200 "this is a response\n";
        }
    }

}
  1. parse and build
  2. The content after rewrite_by_lua has changed.
    original:
    rewrite_by_lua '
        print("rewrite phase")
    ';
    after:
    rewrite_by_lua '\n    print("hello")\n    ';

Expected behavior
*_by_lua directive content can set up a new line for Lua code.

Your environment

  • Operating System: Ubuntu 16.04
  • Version of crossplane: crossplane 0.5.4

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions