albfan / bash-ini-parser

GNU General Public License v3.0
141 stars 46 forks source link

Syntax error on special charachters like & #39

Open jostmart opened 3 years ago

jostmart commented 3 years ago

I get syntax error when parsing repo files that contain & in "value".

bash-ini-parser: eval: line 86: syntax error near unexpected token `&'
bash-ini-parser: eval: line 86: `mirrorlist=( http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=os&infra=$infra )'
bash-ini-parser: eval: line 89: syntax error near unexpected token `}'
bash-ini-parser: eval: line 89: `}'
[centos-kernel]
name=CentOS LTS Kernels for $basearch
mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=kernel&infra=$infra

As a quick test, I escaped & and the example below passes.

[centos-kernel]
name=CentOS LTS Kernels for $basearch
mirrorlist=http://mirrorlist.centos.org/?release=$releasever\&arch=$basearch\&repo=kernel\&infra=$infra
albfan commented 3 years ago

There's an initial section of escaped vars

https://github.com/albfan/bash-ini-parser/blob/master/bash-ini-parser#L30

I expected lot of corner cases for this but at least a failed test to describe what it supports and what it don't would be interesting.

Let me know if you can code something around that