Skip to content

Wrong evaluation of ~character #3

Description

@oktoberfest6

Hi,

According to https://www.rfc-editor.org/rfc/rfc6901#section-4 the string "~01" should be evaluated to "~1" but is currently evaluated to "/"

local jsonpatch = require('jsonpatch')

local o = {
}

local operations = {
	{ op = "add", path = "/~01", value = "value" },
}

print("object before")
for k,v in pairs(o) do print(k, v) end
jsonpatch.apply(o, operations)
print("object after")
for k,v in pairs(o) do print(k, v) end

Result of execution

object before
object after
/	value

I think the two following lines in decode_token

    t = string.gsub(token,"~0","~")
    t = string.gsub(t,"~1","/")

should be swapped into

    t = string.gsub(token,"~1","/")
    t = string.gsub(t,"~0","~")

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions