Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix WFS property format writer for multiline strings #15638

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
16 changes: 15 additions & 1 deletion src/ol/format/WFS.js
Expand Up @@ -25,6 +25,7 @@ import {get as getProjection} from '../proj.js';
import {
readNonNegativeIntegerString,
readPositiveInteger,
writeCDATASection,
writeStringTextNode,
} from './xsd.js';

Expand Down Expand Up @@ -938,7 +939,20 @@ function writeProperty(node, pair, objectStack) {
GML32.prototype.writeGeometryElement(value, pair.value, objectStack);
}
} else {
writeStringTextNode(value, pair.value);
if (typeof pair.value === 'string') {
// Generate CDATA section to preserve whitespaces.
pair.value.split(']]>').forEach((part, i, a) => {
if (i < a.length - 1) {
part += ']]';
}
if (i > 0) {
part = '>' + part;
}
writeCDATASection(value, part);
Copy link
Member

@ahocevar ahocevar Mar 21, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this addition could benefit from a test case.

});
} else {
writeStringTextNode(value, pair.value);
}
}
}
}
Expand Down