Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
15 commits
Select commit Hold shift + click to select a range
1cc3f61
Fix #10540: Escape vertical bar | in cURL (CMD) request snippet body …
Divyanshu-Mishra9620 Oct 8, 2025
5c4a6ff
Merge branch 'master' into fix-#10540-Vertical-bar-character-pipe-not…
Divyanshu-Mishra9620 Oct 8, 2025
cd5a5f4
Fix: Escape vertical bar (|) in cURL (CMD) request snippet body and a…
Divyanshu-Mishra9620 Oct 9, 2025
7817108
Merge branch 'fix-#10540-Vertical-bar-character-pipe-not-escaped-curl…
Divyanshu-Mishra9620 Oct 9, 2025
de1eb15
Merge branch 'master' into fix-#10540-Vertical-bar-character-pipe-not…
Divyanshu-Mishra9620 Oct 9, 2025
52824ee
Update dev-helpers/dev-helper-initializer.js
Divyanshu-Mishra9620 Oct 11, 2025
957a524
Export escapeCMD function from fn.js
Divyanshu-Mishra9620 Oct 11, 2025
7a3f6a3
Remove test for vertical bar escaping in bash
Divyanshu-Mishra9620 Oct 11, 2025
a007477
Enable request snippets in Swagger UI configuration
Divyanshu-Mishra9620 Oct 11, 2025
3be6f2f
Fix vertical bar escaping in CMD and apply code style compliance
Divyanshu-Mishra9620 Oct 14, 2025
26ac9c9
Resolve merge conflicts and maintain style compliance
Divyanshu-Mishra9620 Oct 14, 2025
8061728
Remove dist files and unrelated changes per maintainer feedback
Divyanshu-Mishra9620 Oct 14, 2025
fabb391
Remove dist LICENSE.txt files that shouldn't be in repository
Divyanshu-Mishra9620 Oct 14, 2025
189ed8d
fix: escape vertical bar (|) in CMD request snippets (#10540) and rev…
Divyanshu-Mishra9620 Oct 18, 2025
4c7faf5
Merge branch 'master' into fix-#10540-Vertical-bar-character-pipe-not…
Divyanshu-Mishra9620 Oct 18, 2025
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
Empty file.
Empty file.
Empty file.
Empty file.
4 changes: 2 additions & 2 deletions src/core/components/info.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -97,13 +97,13 @@ class Info extends React.Component {
return (
<div className="info">
<hgroup className="main">
<h1 className="title">
<h2 className="title">
{title}
<span>
{version && <VersionStamp version={version} />}
<OpenAPIVersion oasVersion="2.0" />
</span>
</h1>
</h2>
{host || basePath ? (
<InfoBasePath host={host} basePath={basePath} />
) : null}
Expand Down
2 changes: 1 addition & 1 deletion src/core/components/responses.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -167,4 +167,4 @@ export default class Responses extends React.Component {
</div>
)
}
}
}
4 changes: 2 additions & 2 deletions src/core/plugins/oas31/components/info.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,13 @@ const Info = ({ getComponent, specSelectors }) => {
return (
<div className="info">
<hgroup className="main">
<h1 className="title">
<h2 className="title">
{title}
<span>
{version && <VersionStamp version={version} />}
<OpenAPIVersion oasVersion="3.1" />
</span>
</h1>
</h2>

{(host || basePath) && <InfoBasePath host={host} basePath={basePath} />}
{url && <InfoUrl getComponent={getComponent} url={url} />}
Expand Down
5 changes: 4 additions & 1 deletion src/core/plugins/request-snippets/fn.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,12 @@ const escapeShell = (str) => {
return str
}

const escapeCMD = (str) => {
export const escapeCMD = (str) => {
str = str
.replace(/\^/g, "^^")
.replace(/\\"/g, "\\\\\"")
.replace(/"/g, "\"\"")
.replace(/\|/g, "^|")
.replace(/\n/g, "^\n")
if (str === "-d ") {
return str
Expand Down Expand Up @@ -167,3 +168,5 @@ export const requestSnippetGenerator_curl_bash = (request) => {
export const requestSnippetGenerator_curl_cmd = (request) => {
return curlify(request, escapeCMD, "^\n")
}


10 changes: 3 additions & 7 deletions src/core/utils/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -704,16 +704,12 @@ export const createDeepLinkPath = (str) => typeof str == "string" || str instanc
// suitable for use in CSS classes and ids
export const escapeDeepLinkPath = (str) => cssEscape( createDeepLinkPath(str).replace(/%20/g, "_") )

export const isExtension = (key) => {
const extensionRegExp = /^x-/
return extensionRegExp.test(key)
}

export const getExtensions = (defObj) => {
const extensionRegExp = /^x-/
if(Map.isMap(defObj)) {
return defObj.filter((v, k) => isExtension(k))
return defObj.filter((v, k) => extensionRegExp.test(k))
}
return Object.keys(defObj).filter((key) => isExtension(key))
return Object.keys(defObj).filter((key) => extensionRegExp.test(key))
}
export const getCommonExtensions = (defObj) => defObj.filter((v, k) => /^pattern|maxLength|minLength|maximum|minimum/.test(k))

Expand Down
2 changes: 1 addition & 1 deletion test/e2e-cypress/e2e/bugs/5138.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ describe("#5138: unwanted `url`/`urls` interactions", () => {
it("should stably render the first `urls` entry", () => {
cy
.visit("/pages/5138/")
.get("h1.title")
.get("h2.title")
.contains("USPTO Data Set API")
.wait(3000)
.contains("USPTO Data Set API")
Expand Down
4 changes: 2 additions & 2 deletions test/e2e-cypress/e2e/features/urls.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ describe("configuration options: `urls` and `urls.primaryName`", () => {

it("should render the first URL in the list", () => {
cy.visit("/?configUrl=/configs/urls.yaml")
.get("h1.title")
.get("h2.title")
.should("have.text", "OneOAS 2.0")
.window()
.then(win => win.ui.specSelectors.url())
Expand All @@ -31,7 +31,7 @@ describe("configuration options: `urls` and `urls.primaryName`", () => {
cy.visit("/?configUrl=/configs/urls-primary-name.yaml")
.get("select")
.should("contain.value", "/documents/features/urls/2.yaml")
.get("h1.title")
.get("h2.title")
.should("have.text", "TwoOAS 3.0")
.window()
.then(win => win.ui.specSelectors.url())
Expand Down
Empty file added test/prefixitems-example.yaml
Empty file.
Empty file.
15 changes: 15 additions & 0 deletions test/unit/core/plugins/request-snippets/fn.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@

const { escapeCMD } = require("../../../../../src/core/plugins/request-snippets/fn")

describe("escapeCMD", function() {
it("escapes vertical bar | with caret ^ for CMD", function() {
const input = "foo|bar"
const output = escapeCMD(input)
expect(output).toContain("^|")
})

it("escapes other CMD special characters", function() {
expect(escapeCMD("foo^bar")).toContain("^^")
expect(escapeCMD("foo\"bar")).toContain("\"\"")
})
})