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

WEBUI-1510: Backward Port: Own Code Static Scan : Cross-Site Scripting (XSS) #2242

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,6 @@ import { config } from '@nuxeo/nuxeo-elements';
import { FormatBehavior } from '@nuxeo/nuxeo-ui-elements/nuxeo-format-behavior.js';
import { RoutingBehavior } from '@nuxeo/nuxeo-ui-elements/nuxeo-routing-behavior.js';

let schemaFetcher = null;

/**
* `Nuxeo.DocumentCreationBehavior`
*
Expand Down Expand Up @@ -78,24 +76,34 @@ export const DocumentCreationBehavior = [
subtypes: {
type: Array,
},

_resource: {
type: Object,
readOnly: true,
},
},

get resource() {
if (!this._resource) {
this._set_resource(document.createElement('nuxeo-resource'));
this.shadowRoot.appendChild(this._resource);
}
return this._resource;
},

observers: ['_validateLocation(isValidTargetPath,suggesterChildren)', '_updateDocument(selectedDocType, parent)'],

newDocument(type, properties) {
if (!schemaFetcher) {
schemaFetcher = document.createElement('nuxeo-resource');
this.shadowRoot.appendChild(schemaFetcher);
}
schemaFetcher.path = `path/${this.targetPath}/@emptyWithDefault`;
schemaFetcher.params = { type: this.selectedDocType.type };
schemaFetcher.headers = {
const { resource } = this;
resource.path = `path/${this.targetPath}/@emptyWithDefault`;
resource.params = { type: this.selectedDocType.type };
resource.headers = {
properties: '*',
'fetch-document': 'properties',
'translate-directoryEntry': 'label',
};
schemaFetcher.enrichers = config.get('enrichers', {});
return schemaFetcher.get().then((doc) => {
resource.enrichers = config.get('enrichers', {});
return resource.get().then((doc) => {
if (properties) {
Object.keys(properties).forEach((prop) => {
doc.properties[prop] = properties[prop];
Expand Down
Loading