Skip to content

Commit

Permalink
Merge branch 'master' into chore-swagger-ui-dist-docs
Browse files Browse the repository at this point in the history
  • Loading branch information
webron authored Jun 8, 2017
2 parents 531e5d1 + 60a9dc4 commit 284f187
Show file tree
Hide file tree
Showing 13 changed files with 106 additions and 75 deletions.
2 changes: 1 addition & 1 deletion .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
"rules": {
"semi": [2, "never"],
"strict": 0,
"quotes": 2,
"quotes": [2, "double", { "allowTemplateLiterals": true }],
"no-unused-vars": 2,
"no-multi-spaces": 1,
"camelcase": 1,
Expand Down
6 changes: 3 additions & 3 deletions dist/oauth2-redirect.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
function run () {
var oauth2 = window.opener.swaggerUIRedirectOauth2;
var sentState = oauth2.state;
var redirectUrl = oauth2.redirectUrl;
var isValid, qp, arr;

qp = (window.location.hash || location.search).substring(1);
Expand Down Expand Up @@ -35,7 +36,7 @@
if (qp.code) {
delete oauth2.state;
oauth2.auth.code = qp.code;
oauth2.callback(oauth2.auth);
oauth2.callback({auth: oauth2.auth, redirectUrl: redirectUrl});
} else {
oauth2.errCb({
authId: oauth2.auth.name,
Expand All @@ -45,9 +46,8 @@
});
}
} else {
oauth2.callback({auth: oauth2.auth, token: qp, isValid: isValid});
oauth2.callback({auth: oauth2.auth, token: qp, isValid: isValid, redirectUrl: redirectUrl});
}
window.close();
}

</script>
98 changes: 49 additions & 49 deletions dist/swagger-ui-bundle.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/swagger-ui-bundle.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 7 additions & 7 deletions dist/swagger-ui-standalone-preset.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/swagger-ui-standalone-preset.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/swagger-ui.css

Large diffs are not rendered by default.

14 changes: 7 additions & 7 deletions dist/swagger-ui.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/swagger-ui.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
"test": "npm run lint-errors && npm run just-test-in-node",
"test-in-node": "npm run lint-errors && npm run just-test-in-node",
"just-test": "karma start --config karma.conf.js",
"just-test-in-node": "mocha --recursive --compilers js:babel-core/register test/core test/components"
"just-test-in-node": "mocha --recursive --compilers js:babel-core/register test/core test/components test/bugs"
},
"dependencies": {
"babel-polyfill": "^6.23.0",
Expand Down
5 changes: 3 additions & 2 deletions src/core/components/auth/oauth2.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export default class Oauth2 extends React.Component {
let username = auth && auth.get("username") || ""
let clientId = auth && auth.get("clientId") || authConfigs.clientId || ""
let clientSecret = auth && auth.get("clientSecret") || authConfigs.clientSecret || ""
let passwordType = auth && auth.get("passwordType") || "basic"
let passwordType = auth && auth.get("passwordType") || "request-body"

this.state = {
appName: authConfigs.appName,
Expand Down Expand Up @@ -97,12 +97,13 @@ export default class Oauth2 extends React.Component {
let isAuthorized = !!authorizedAuth
let errors = errSelectors.allErrors().filter( err => err.get("authId") === name)
let isValid = !errors.filter( err => err.get("source") === "validation").size
let description = schema.get("description")

return (
<div>
<h4>OAuth2.0 <JumpToPath path={[ "securityDefinitions", name ]} /></h4>
{ !this.state.appName ? null : <h5>Application: { this.state.appName } </h5> }
<Markdown source={ schema.get("description") } />
{ description && <Markdown source={ schema.get("description") } /> }

{ isAuthorized && <h6>Authorized</h6> }

Expand Down
9 changes: 8 additions & 1 deletion src/core/components/providers/markdown.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,15 @@ import React, { PropTypes } from "react"
import Remarkable from "react-remarkable"
import sanitize from "sanitize-html"

const sanitizeOptions = {
textFilter: function(text) {
return text
.replace(/&quot;/g, "\"")
}
}

function Markdown({ source }) {
const sanitized = sanitize(source)
const sanitized = sanitize(source, sanitizeOptions)
return <Remarkable
options={{html: true, typographer: true, linkify: true, linkTarget: "_blank"}}
source={sanitized}
Expand Down
23 changes: 23 additions & 0 deletions test/bugs/3199-sanitization-escaping.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
/* eslint-env mocha */
import React from "react"
import expect from "expect"
import { render } from "enzyme"
import Markdown from "components/providers/markdown"

describe("UI-3199: Sanitized Markdown causing code examples to be double escaped", function(){
it("should single-escape quotes", function(){

let str = "" +
"This is a test: \n\n" +
" {\"abc\": \"def\"}\n"

let props = {
source: str
}

let el = render(<Markdown {...props}/>)

expect(el.find("code").first().text()).toEqual("{\"abc\": \"def\"}\n")
expect(el.find("code").first().html()).toEqual("{&quot;abc&quot;: &quot;def&quot;}\n")
})
})

0 comments on commit 284f187

Please sign in to comment.