speedata / publisher

speedata Publisher - a professional database Publishing system
https://www.speedata.de/
GNU Affero General Public License v3.0
292 stars 36 forks source link

variables with backslashes #411

Closed pr-apes closed 2 years ago

pr-apes commented 2 years ago

@pgundlach,

having this layout:

<Layout xmlns="urn:speedata.de:2009/publisher/en"
  xmlns:sd="urn:speedata:2009/publisher/functions/en">

  <Record element="data">
    <PlaceObject>
      <Textblock>
        <Paragraph>
          <Value select="if (sd:variable-exists('cfn')) then 'yes' else 'no'"/>
        </Paragraph>
      </Textblock>
    </PlaceObject>
  </Record>

</Layout>

The following invocation sp --dummy -v cfn="\a\b\c" outputs no, but sp --dummy -v cfn="\a\b" outputs yes.

This may be the underlying cause of #409. I’m afraid that backslashes are essential for complete paths in Windows (this is what I’m trying to pass as variable [through a batch file]).

Many thanks for your help.

pgundlach commented 2 years ago

Can you create a simple filter such as the following to show the variables?

runtime = require("runtime")

for key, value in pairs(runtime.variables) do
    print(key,string.format("%q",value))
end

os.exit(0)
pr-apes commented 2 years ago

My results are the following:

>sp --filter a.lua -v cfn="\a\b"
cfn     "\\a\\b"

>sp --filter a.lua -v cfn="\a\b\c"
cfn     "\\a\\b\\c"

The first value for cfn variable would output yes and the second value would output no.

I wonder whether you need other data for this.

Many thanks for your help.

pgundlach commented 2 years ago

OK, thanks, this will be fixed in the next version.

pr-apes commented 2 years ago

Many thanks for your help.