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

configure_file breaks Perl code: transforms e.g. \@array to @array #7165

Closed
stapelberg opened this issue May 18, 2020 · 2 comments · Fixed by #13302
Closed

configure_file breaks Perl code: transforms e.g. \@array to @array #7165

stapelberg opened this issue May 18, 2020 · 2 comments · Fixed by #13302
Labels

Comments

@stapelberg
Copy link

Describe the bug
A clear and concise description of what the bug is.

To Reproduce

minimal example:

cat > foo.pl.in <<'EOT'
#!/usr/bin/env perl

use strict;
use warnings;

use lib qw(@abs_top_builddir@);

my @array = qw(1 2);
use Data::Dumper;
say Dumper(\@array);
EOT
cat > meson.build <<'EOT'
project('broken')

test_cdata = configuration_data()
test_cdata.set('abs_top_builddir', meson.current_build_dir())

complete_run = configure_file(
    input: 'foo.pl.in',
    output: 'foo.pl',
    configuration: test_cdata,
)
EOT
mkdir build
cd build
meson ..
diff -u ../foo.pl.in foo.pl

Expected behavior

Only @abs_top_builddir@ should be replaced, and \@array should be left unmodified.

system parameters

  • Arch Linux
  • Python version: 3.8.1
  • meson --version: 0.53.2
  • ninja --version: 1.10.0
@dcbaker dcbaker added the bug label May 22, 2020
@Kangie
Copy link
Contributor

Kangie commented Apr 18, 2024

see also #13091

Exactly the same issue, identified in the same way, with the same proposed solution.

@jpakkane
Copy link
Member

The real problem here is predicting if changing the behaviour so that @BOB is not touched, will any downstream users break. Though I guess breaking a few is ok, but no large scale breakage. We don't really have a good way of testing whether that is the case. Rebuilding all of WrapDB is a good start, but most of Meson code is not there, sadly.

Kangie added a commit to Kangie/meson that referenced this issue Jun 6, 2024
Update meson logic to only handle matched pairs of \@ when
escaping variables in 'meson' and 'cmake@' style configure_file
invocations.

The previous approach, using a regex to handle a single  \@
to escape a variable has undesirable side effects,
including mangling valid perl that needs to be configured.

Closes: mesonbuild#7165
Kangie added a commit to Kangie/meson that referenced this issue Jun 6, 2024
Update meson logic to only handle matched pairs of \@ when
escaping variables in 'meson' and 'cmake@' style configure_file
invocations.

The previous approach, using a regex to handle a single  \@
to escape a variable has undesirable side effects,
including mangling valid perl that needs to be configured.

Closes: mesonbuild#7165
Kangie added a commit to Kangie/meson that referenced this issue Jun 6, 2024
Update meson logic to only handle matched pairs of \@ when
escaping variables in 'meson' and 'cmake@' style configure_file
invocations.

The previous approach, using a regex to handle a single  \@
to escape a variable has undesirable side effects,
including mangling valid perl that needs to be configured.

Closes: mesonbuild#7165
Kangie added a commit to Kangie/meson that referenced this issue Jun 6, 2024
Update meson logic to only handle matched pairs of \@ when
escaping variables in 'meson' and 'cmake@' style configure_file
invocations.

The previous approach, using a regex to handle a single  \@
to escape a variable has undesirable side effects,
including mangling valid perl that needs to be configured.

Closes: mesonbuild#7165
Kangie added a commit to Kangie/meson that referenced this issue Jun 6, 2024
Update meson logic to only consider matched pairs of `\@`
when escaping variables in 'meson' and 'cmake@'
style configure_file invocations.

The previous approach, escaping a single `\@`,
had undesirable side effects, including mangling valid
perl is being configured.

Closes: mesonbuild#7165
Kangie added a commit to Kangie/meson that referenced this issue Jun 6, 2024
Update meson logic to only consider matched pairs of `\@`
when escaping variables in 'meson' and 'cmake@'
style configure_file invocations.

The previous approach, escaping a single `\@`,
had undesirable side effects, including mangling valid
perl is being configured.

Closes: mesonbuild#7165
Kangie added a commit to Kangie/meson that referenced this issue Jun 6, 2024
Update meson logic to only consider matched pairs of `\@`
when escaping variables in 'meson' and 'cmake@'
style configure_file invocations.

The previous approach, escaping a single `\@`,
had undesirable side effects, including mangling valid
perl that is being configured.

Closes: mesonbuild#7165
Kangie added a commit to Kangie/meson that referenced this issue Jun 6, 2024
Update meson logic to only consider matched pairs of `\@`
when escaping variables in 'meson' and 'cmake@'
style `configure_file` invocations.

The previous approach, escaping a single `\@`,
had undesirable side effects, including mangling valid
perl that is being configured.

Closes: mesonbuild#7165
Kangie added a commit to Kangie/meson that referenced this issue Jun 6, 2024
Update meson logic to only consider matched pairs of `\@`
when escaping variables in 'meson' and 'cmake@'
style `configure_file` invocations.

The previous approach, escaping a single `\@`,
had undesirable side effects, including mangling valid
perl that is being configured.

Closes: mesonbuild#7165
Kangie added a commit to Kangie/meson that referenced this issue Jun 18, 2024
When configuring a 'meson' or 'cmake@' style file,
add a case for escaped variables using matched pairs of
`\@` i.e. `\@foo\@ -> @foo@`.

The match for @var@ has been amended with a negative lookbehind
to ensure that any occurrances of `\@foo@` are not evaluated to
`\bar`.

The previous behaviour, matching `\@` and escaping only that character,
had undesirable side effects including mangling valid perl when
configuring files.

Closes: mesonbuild#7165
Kangie added a commit to Kangie/meson that referenced this issue Jun 18, 2024
When configuring a 'meson' or 'cmake@' style file,
add a case for escaped variables using matched pairs of
`\@` i.e. `\@foo\@ -> @foo@`.

The match for @var@ has been amended with a negative lookbehind
to ensure that any occurrances of `\@foo@` are not evaluated to
`\bar`.

The previous behaviour, matching `\@` and escaping only that character,
had undesirable side effects including mangling valid perl when
configuring files.

Closes: mesonbuild#7165
jpakkane pushed a commit that referenced this issue Jun 23, 2024
When configuring a 'meson' or 'cmake@' style file,
add a case for escaped variables using matched pairs of
`\@` i.e. `\@foo\@ -> @foo@`.

The match for @var@ has been amended with a negative lookbehind
to ensure that any occurrances of `\@foo@` are not evaluated to
`\bar`.

The previous behaviour, matching `\@` and escaping only that character,
had undesirable side effects including mangling valid perl when
configuring files.

Closes: #7165
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants