{"id":15436999,"url":"https://github.com/ucarion/c14n","last_synced_at":"2025-04-19T19:02:40.332Z","repository":{"id":144212332,"uuid":"263819428","full_name":"ucarion/c14n","owner":"ucarion","description":"A Golang implementation of XML canonicalization","archived":false,"fork":false,"pushed_at":"2020-05-29T19:00:13.000Z","size":60,"stargazers_count":19,"open_issues_count":0,"forks_count":3,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-04-16T15:14:47.075Z","etag":null,"topics":["c14n","golang","xml"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ucarion.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-05-14T05:00:39.000Z","updated_at":"2025-02-23T05:18:58.000Z","dependencies_parsed_at":null,"dependency_job_id":"9fda7980-1a0a-46ce-9515-7c2c76fed03d","html_url":"https://github.com/ucarion/c14n","commit_stats":{"total_commits":27,"total_committers":2,"mean_commits":13.5,"dds":"0.14814814814814814","last_synced_commit":"5ce1356136f8b0c97950f4a8cf179a23dc3c4678"},"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ucarion%2Fc14n","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ucarion%2Fc14n/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ucarion%2Fc14n/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ucarion%2Fc14n/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ucarion","download_url":"https://codeload.github.com/ucarion/c14n/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":249771339,"owners_count":21323079,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["c14n","golang","xml"],"created_at":"2024-10-01T18:54:37.380Z","updated_at":"2025-04-19T19:02:40.298Z","avatar_url":"https://github.com/ucarion.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# c14n\n\n [![go.dev reference](https://img.shields.io/badge/go.dev-reference-007d9c?logo=go\u0026logoColor=white\u0026style=flat-square)](https://pkg.go.dev/mod/github.com/ucarion/c14n?tab=overview)\n [![GitHub Workflow Status](https://img.shields.io/github/workflow/status/ucarion/c14n/tests?label=tests\u0026logo=github\u0026style=flat-square)](https://github.com/ucarion/c14n/actions)\n\nThis package is a Golang implementation of XML Canonicalization (\"c14n\"). In\nparticular, it implements the [Exclusive Canonical XML][w3] specification, which\nis the recommended canonicalization scheme used in SAML.\n\nIf you're looking to canonicalize XML because you're implementing SAML or XML\nDigital Signature, consider using [`github.com/ucarion/saml`][saml] or\n[`github.com/ucarion/dsig`][dsig], which are implemented using this package.\n\n[w3]: https://www.w3.org/TR/xml-exc-c14n/\n[saml]: https://github.com/ucarion/saml\n[dsig]: https://github.com/ucarion/dsig\n\n## Installation\n\nInstall this package by running:\n\n```bash\ngo get github.com/ucarion/c14n\n```\n\n## Usage\n\nThe most common way to use this package is to call `c14n.Canonicalize` with a\n`xml.Decoder`:\n\n```go\ninput := `\u003cfoo z=\"2\" a=\"1\"\u003e\u003cbar /\u003e\u003c/foo\u003e`\ndecoder := xml.NewDecoder(strings.NewReader(input))\nout, err := c14n.Canonicalize(decoder)\nfmt.Println(string(out), err)\n// Output:\n// \u003cfoo a=\"1\" z=\"2\"\u003e\u003cbar\u003e\u003c/bar\u003e\u003c/foo\u003e \u003cnil\u003e\n```\n\n## Limitations\n\nThis package ignores processing directives, and so technically does not fully\ncomply with the Exclusive Canonical XML spec. In particular, the spec says that\nif you have a document like this:\n\n```xml\n\u003c!DOCTYPE doc [\n\u003c!ENTITY ent1 \"Hello\"\u003e\n\u003c!ENTITY ent2 SYSTEM \"world.txt\"\u003e\n]\u003e\n\u003cdoc attrExtEnt=\"entExt\"\u003e\n   \u0026ent1;, \u0026ent2;!\n\u003c/doc\u003e\n\n\u003c!-- Assume world.txt contains \"world\" (excluding the quotes) --\u003e\n```\n\nThen it should be canonicalized as:\n\n```xml\n\u003cdoc attrExtEnt=\"entExt\"\u003e\n   Hello, world!\n\u003c/doc\u003e\n```\n\nBut in order to do that, this package would need to potentially do I/O in order\nto work, and it would need to understand the entire DTD spec. Furthermore, the\nstandard library's XML decoder doesn't support parsing custom entities (instead,\nit errors out), so this package would need to ship an alternative to\n`xml.Decoder`.\n\nThus, this package does not support custom entities and other features driven by\nprocessing directives. In practice, these features are rarely used in common\nprotocols like SAML.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fucarion%2Fc14n","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fucarion%2Fc14n","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fucarion%2Fc14n/lists"}