Skip to content

Escape non-ASCII characters in properties files #53

@olim7t

Description

@olim7t

Cassandra allows non-ASCII characters in datacenter names, for example DåtåCenter1.

However, the cassandra-rackdc.properties file is decoded using ISO-8859-1, so it needs to use Unicode escapes:

dc=D\u00e5t\u00e5Center1

Currently this is not the case, cass-config-builder writes the unescaped Unicode string:

# Wrong, Cassandra won't decode this properly
dc=DåtåCenter1

Minimal test to reproduce this in build_config_test.clj:

(deftest test-non-ascii-dc
  (let [datacenter-info {:name "DåtåCenter1"}
        definitions-data (test-data/get-definitions-data "cassandra" helper/default-cassandra-version)
        built-configs (bc/build-configs definitions-data {:datacenter-info datacenter-info})]
    (is (= "D\\u00e5t\\u00e5Center1" (get-in built-configs [:cassandra-rackdc-properties :dc])))
  )
)

(This potentially extends to other properties files, I haven't compiled an extensive list.)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions