Skip to content

Commit

Permalink
WEBUI-1510: Own Code Static Scan : Cross-Site Scripting (XSS)
Browse files Browse the repository at this point in the history
  • Loading branch information
rahuljain-dev committed May 20, 2024
1 parent a703db4 commit cc8d335
Showing 1 changed file with 19 additions and 11 deletions.
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

0 comments on commit cc8d335

Please sign in to comment.