Skip to content
Open
Show file tree
Hide file tree
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
3 changes: 2 additions & 1 deletion packages/elements-core/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@stoplight/elements-core",
"version": "9.0.6",
"version": "9.0.7",
"sideEffects": [
"web-components.min.js",
"src/web-components/**",
Expand Down Expand Up @@ -72,6 +72,7 @@
"@stoplight/types": "^14.1.1",
"@stoplight/yaml": "^4.3.0",
"classnames": "^2.2.6",
"dompurify": "^3.2.6",
"httpsnippet-lite": "^3.0.5",
"jotai": "1.3.9",
"json-schema": "^0.4.0",
Expand Down
10 changes: 7 additions & 3 deletions packages/elements-core/src/components/TryIt/build-request.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { Dictionary, HttpParamStyles, IHttpOperation, IMediaTypeContent, IServer } from '@stoplight/types';
import DOMPurify from 'dompurify';
import { Request as HarRequest } from 'har-format';

import { getServerUrlWithVariableValues, resolveUrl } from '../../utils/http-spec/IServer';
Expand Down Expand Up @@ -144,20 +145,23 @@ export async function buildFetchRequest({
credentials = 'omit',
corsProxy,
}: BuildRequestInput): Promise<Parameters<typeof fetch>> {
const sanitizedParameterValues = Object.fromEntries(
Object.entries(parameterValues).map(([key, value]) => [key, DOMPurify.sanitize(value)]),
);
const serverUrl = getServerUrl({ httpOperation, mockData, chosenServer, corsProxy, serverVariableValues });

const shouldIncludeBody =
['PUT', 'POST', 'PATCH'].includes(httpOperation.method.toUpperCase()) && bodyInput !== undefined;

const queryParams = getQueryParams({ httpOperation, parameterValues });
const queryParams = getQueryParams({ httpOperation, parameterValues: sanitizedParameterValues });

const rawHeaders = filterOutAuthorizationParams(httpOperation.request?.headers ?? [], httpOperation.security)
.map(header => ({ name: header.name, value: parameterValues[header.name] ?? '' }))
.map(header => ({ name: header.name, value: sanitizedParameterValues[header.name] ?? '' }))
.filter(({ value }) => value.length > 0);

const [queryParamsWithAuth, headersWithAuth] = runAuthRequestEhancements(auth, queryParams, rawHeaders);

const expandedPath = uriExpand(httpOperation.path, parameterValues);
const expandedPath = uriExpand(httpOperation.path, sanitizedParameterValues);

// urlObject is concatenated this way to avoid /user and /user/ endpoint edge cases
const urlObject = new URL(serverUrl + expandedPath);
Expand Down
4 changes: 2 additions & 2 deletions packages/elements-dev-portal/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@stoplight/elements-dev-portal",
"version": "3.0.6",
"version": "3.0.7",
"description": "UI components for composing beautiful developer documentation.",
"keywords": [],
"sideEffects": [
Expand Down Expand Up @@ -66,7 +66,7 @@
"dependencies": {
"@stoplight/markdown-viewer": "^5.7.1",
"@stoplight/mosaic": "^1.53.4",
"@stoplight/elements-core": "~9.0.6",
"@stoplight/elements-core": "~9.0.7",
"@stoplight/path": "^1.3.2",
"@stoplight/types": "^14.0.0",
"classnames": "^2.2.6",
Expand Down
6 changes: 3 additions & 3 deletions packages/elements/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@stoplight/elements",
"version": "9.0.6",
"version": "9.0.7",
"description": "UI components for composing beautiful developer documentation.",
"keywords": [],
"sideEffects": [
Expand Down Expand Up @@ -63,7 +63,7 @@
]
},
"dependencies": {
"@stoplight/elements-core": "~9.0.4",
"@stoplight/elements-core": "~9.0.7",
"@stoplight/http-spec": "^7.1.0",
"@stoplight/json": "^3.18.1",
"@stoplight/mosaic": "^1.53.4",
Expand Down Expand Up @@ -109,4 +109,4 @@
"release": {
"extends": "@stoplight/scripts/release"
}
}
}
Loading