Skip to content

Commit

Permalink
bump xmldom to 0.6.0 to avoid bug where it keeps "<" in attributes (#…
Browse files Browse the repository at this point in the history
…1974)

* bump xmldom to 0.6.0 to avoid bug where it keeps "<" in attributes
see xmldom/xmldom#198

* add test which fails on version of 0.5.0 because of bad serialization
* add valid entity serialization test
* move serialization test down to serializer package instead of up at transformer level
* better test name not referencing round trip

Co-authored-by: Michael Belousov <MichaelBelousov@users.noreply.github.com>
  • Loading branch information
2 people authored and khanaffan committed Aug 10, 2021
1 parent 36ce884 commit 9c8ed9a
Show file tree
Hide file tree
Showing 12 changed files with 100 additions and 15 deletions.
2 changes: 1 addition & 1 deletion clients/itwin/package.json
Expand Up @@ -65,7 +65,7 @@
"lodash": "^4.17.10",
"qs": "^6.5.1",
"superagent": "^5.2.2",
"xmldom": "^0.5.0",
"xmldom": "^0.6.0",
"xpath": "0.0.27"
},
"nyc": {
Expand Down
@@ -0,0 +1,11 @@
{
"changes": [
{
"packageName": "@bentley/ecschema-editing",
"comment": "switch to xmldom@0.6.0 which correctly escapes entities in attributes when serializing",
"type": "none"
}
],
"packageName": "@bentley/ecschema-editing",
"email": "MichaelBelousov@users.noreply.github.com"
}
@@ -0,0 +1,11 @@
{
"changes": [
{
"packageName": "@bentley/ecschema-locaters",
"comment": "switch to xmldom@0.6.0 which correctly escapes entities in attributes when serializing",
"type": "none"
}
],
"packageName": "@bentley/ecschema-locaters",
"email": "MichaelBelousov@users.noreply.github.com"
}
@@ -0,0 +1,11 @@
{
"changes": [
{
"packageName": "@bentley/ecschema-metadata",
"comment": "switch to xmldom@0.6.0 which correctly escapes entities in attributes when serializing",
"type": "none"
}
],
"packageName": "@bentley/ecschema-metadata",
"email": "MichaelBelousov@users.noreply.github.com"
}
@@ -0,0 +1,11 @@
{
"changes": [
{
"packageName": "@bentley/ecschema2ts",
"comment": "switch to xmldom@0.6.0 which correctly escapes entities in attributes when serializing",
"type": "none"
}
],
"packageName": "@bentley/ecschema2ts",
"email": "MichaelBelousov@users.noreply.github.com"
}
@@ -0,0 +1,11 @@
{
"changes": [
{
"packageName": "@bentley/itwin-client",
"comment": "switch to xmldom@0.6.0 which correctly escapes entities in attributes when serializing",
"type": "none"
}
],
"packageName": "@bentley/itwin-client",
"email": "MichaelBelousov@users.noreply.github.com"
}
25 changes: 15 additions & 10 deletions common/config/rush/pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion core/ecschema-editing/package.json
Expand Up @@ -59,7 +59,7 @@
"rimraf": "^3.0.2",
"sinon": "^9.0.2",
"typescript": "~4.3.0",
"xmldom": "^0.5.0",
"xmldom": "^0.6.0",
"xmlhttprequest": "^1.8.0"
},
"peerDependencies": {
Expand Down
2 changes: 1 addition & 1 deletion core/ecschema-locaters/package.json
Expand Up @@ -48,7 +48,7 @@
"nyc": "^15.1.0",
"rimraf": "^3.0.2",
"typescript": "~4.3.0",
"xmldom": "^0.5.0"
"xmldom": "^0.6.0"
},
"dependencies": {
"glob": "^7.1.2"
Expand Down
2 changes: 1 addition & 1 deletion core/ecschema-metadata/package.json
Expand Up @@ -58,7 +58,7 @@
"rimraf": "^3.0.2",
"sinon": "^9.0.2",
"typescript": "~4.3.0",
"xmldom": "^0.5.0",
"xmldom": "^0.6.0",
"xmlhttprequest": "^1.8.0"
},
"peerDependencies": {
Expand Down
@@ -0,0 +1,25 @@
/*---------------------------------------------------------------------------------------------
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
* See LICENSE.md in the project root for license terms and full copyright notice.
*--------------------------------------------------------------------------------------------*/

import { assert } from "chai";
import { SchemaContext } from "../../Context";
import { MutableSchema, Schema } from "../../Metadata/Schema";
import { MutableEntityClass } from "../../Metadata/EntityClass";

describe("XmlSerializer", () => {
it("try serializing attributes with html entities '<' '&' ", async () => {
const ctx = new SchemaContext();
const schema = new Schema(ctx, "TestSchema", "ts", 1, 0, 0) as MutableSchema;
const entityClass = (await schema.createEntityClass("TestElement")) as MutableEntityClass;
entityClass.setDisplayLabel("escape < us & please; except > I'm ok apparently");
const serializedXml = await schema.toXmlString();

// use regex to find the displayLabel quote, because the DOMParser implementation could be lenient
assert(
/displayLabel\s*=\s*"escape &lt; us &amp; please; except > I'm ok apparently"/.test(serializedXml),
"< and & must be escaped in serialized xml"
);
});
});
2 changes: 1 addition & 1 deletion tools/ecschema2ts/package.json
Expand Up @@ -68,7 +68,7 @@
"chalk": "^3.0.0",
"commander": "^2.14.1",
"fs-extra": "^8.1.0",
"xmldom": "^0.5.0"
"xmldom": "^0.6.0"
},
"nyc": {
"extends": "./node_modules/@bentley/build-tools/.nycrc"
Expand Down

0 comments on commit 9c8ed9a

Please sign in to comment.