npm / ini

An ini parser/serializer in JavaScript

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

[BUG] Problem with # in value ini

kchojnacki opened this issue · comments

What / Why

Problem with # in value ini

n/a

When

string in ini have #

  • n/a

Where

`function unsafe (val, doUnesc) {
val = (val || '').trim()
if (isQuoted(val)) {
// remove the single quotes before calling JSON.parse
if (val.charAt(0) === "'")
val = val.substr(1, val.length - 2)

try {
  val = JSON.parse(val)
} catch (_) {}

} else {
// walk the val to find the first not-escaped ; character
var esc = false
var unesc = ''
for (var i = 0, l = val.length; i < l; i++) {
var c = val.charAt(i)
if (esc) {
if ('\;#'.indexOf(c) !== -1)
unesc += c
else
unesc += '\' + c

    esc = false
  } else if (';#'.indexOf(c) !== -1)
    break
  else if (c === '\\')
    esc = true
  else
    unesc += c
}
if (esc)
  unesc += '\\'

return unesc.trim()

}
return val
}`

  • n/a

How

Current Behavior

  • n/a

Steps to Reproduce

  • n/a

Expected Behavior

You need to delete # in :

} else if (';#'.indexOf(c) !== -1)

and

if ('\;#'.indexOf(c) !== -1)

to:

} else if (';'.indexOf(c) !== -1)

and

if ('\;'.indexOf(c) !== -1)

  • n/a

Who

  • n/a

References

  • n/a

i am having the same

You can try my fork, ini-win, which aims to be more compatible with the way Windows handles ini files. Windows only supports whole line comments, and so does my fork, so it fixes this issue.