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

Quotes added disabling a location #84

Open
PiTiLeZarD opened this issue Jun 4, 2020 · 3 comments
Open

Quotes added disabling a location #84

PiTiLeZarD opened this issue Jun 4, 2020 · 3 comments

Comments

@PiTiLeZarD
Copy link

PiTiLeZarD commented Jun 4, 2020

Describe the bug
I discovered while using crossplane that my locations weren't used by nginx due to quotes added in the build process

To Reproduce
Here is a quick python example showing what I mean:

# -*- coding: utf-8 -*-
from crossplane import parse, build

testConfig = """
http {
    server {
        listen 8080;
        location ~ \\.php$ {
            return 200 'success';
        }
    }
}
"""
inFile = './testconf.conf'
outFile = './testconf.out.conf'

with open(inFile, 'w') as f:
    f.write(testConfig)

with open(outFile, 'w') as f:
    parsed = parse(inFile)['config'][0]['parsed']
    f.write(build(parsed))

This will output: location ~ '\.php$' {

Expected behavior

I expect it to output: location ~ \.php$ { (without the quotes)

Your environment

  • crossplane 0.5.4
  • python 3.8.2

Additional context

I fixed my issue by using location labels @php but It's hardly a solution. I haven't looked into the source code yet, let me know if I can be of any help.

Not sure if this is related to this other issue: #82 if it is, you can close mine.

@ornj
Copy link
Member

ornj commented Jun 5, 2020

While the quotes may not be necessary for this regex pattern, crossplane is not changing the behavior of this configuration by including them. If the request is not matching then I suspect fault lies else where.

Your expected behavior shows a pattern with the backslash to escape the "." stripped. Why do you expect that to happen?

@PiTiLeZarD
Copy link
Author

First thanks for answering, and full disclosure, I'm far from an nginx expert. But I've discovered that my php rule wasn't matching properly with the quotes and was working fine without them.

Either way, if the original configuration doesn't have them, it'd be good for idempotence to have in and out matching I reckon, I'm happy to hear where I'm mistaken on this one.

Also I don't expect the backslash to disappear, I forgot to double escape the second one while writing the report, I've fixed the original bug report with the backslash in the "expected" section, sorry about that.

@aluttik
Copy link
Contributor

aluttik commented Jul 13, 2020

@PiTiLeZarD I tried out the config with and without quotes around \.php$, but I couldn't find any difference in behavior with the two. Do you have an example url that would be routed by one but not the other?

Crossplane's build function is only intended to be idempotent as it pertains to the behavior of nginx. In other words, if you build a new config from a payload you previously parsed from an original config, the new config may look a bit different (e.g. indentation, blank lines, quotation), but nginx should act in exactly the same way when using either config.

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

3 participants