Skip to content

Console: Escaping results in differently stored documents #13528

@spinscale

Description

@spinscale

Escaping using the three ticks syntax in combination with backslashes can result in differently stored documents (maybe this is documented and I didnt find it, but I think it's worth mentioning somewhere). Take this example

PUT foo/bar/1
{
  "message" : """
*\\!DMAlock*_
"""
}

PUT foo/bar/2
{
  "message" : "*\\!DMAlock*_"
}

GET foo/bar/_mget
{"ids":["1","2"]}

# response
{
  "docs": [
    {
      "_index": "foo",
      "_type": "bar",
      "_id": "1",
      "_version": 3,
      "found": true,
      "_source": {
        "message": """*\\!DMAlock*_"""
      }
    },
    {
      "_index": "foo",
      "_type": "bar",
      "_id": "2",
      "_version": 1,
      "found": true,
      "_source": {
        "message": "*\\!DMAlock*_"
      }
    }
  ]
}

As you can see, the response looks fine. However returning the documents via curl reveal, that the source is actually different

curl -u elastic:changeme localhost:9200/foo/bar/_mget?pretty -d '{"ids":["1","2"]}'
{
  "docs" : [
    {
      "_index" : "foo",
      "_type" : "bar",
      "_id" : "1",
      "_version" : 3,
      "found" : true,
      "_source" : {
        "message" : "*\\\\!DMAlock*_"
      }
    },
    {
      "_index" : "foo",
      "_type" : "bar",
      "_id" : "2",
      "_version" : 1,
      "found" : true,
      "_source" : {
        "message" : "*\\!DMAlock*_"
      }
    }
  ]
}

As you can see the number of backslashes is different, two versus four.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Feature:ConsoleDev Tools Console FeatureFeature:Dev ToolsTeam:Kibana ManagementDev Tools, Index Management, Upgrade Assistant, ILM, Ingest Node Pipelines, and morebugFixes for quality problems that affect the customer experience

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions