Skip to content

Commit d89f6d1

Browse files
committed
PM-197 - XSS poor validation error handling
1 parent 586476c commit d89f6d1

File tree

10 files changed

+15
-15
lines changed

10 files changed

+15
-15
lines changed

src/shared/components/Contentful/Article/Article.jsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ class Article extends React.Component {
139139
} = this.state || {};
140140
let shareUrl;
141141
if (isomorphy.isClientSide()) {
142-
shareUrl = encodeURIComponent(window.location.href);
142+
shareUrl = encodeURIComponent(`${window.location.origin}${window.location.pathname}`);
143143
}
144144
const description = htmlToText.fromString(
145145
ReactDOMServer.renderToString(markdown(fields.content)),

src/shared/components/Gigs/GigApply/index.jsx

+3-3
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ export default function GigApply(props) {
3636
recruitProfile,
3737
auth,
3838
} = props;
39-
const retUrl = window.location.href;
39+
const retUrl = encodeURIComponent(`${window.location.origin}${window.location.pathname}`);
4040
const duration = getCustomField(job.custom_fields, 'Duration');
4141
const isPlaced = _.find(_.isEmpty(recruitProfile) ? [] : recruitProfile.custom_fields, { field_id: 12 });
4242
const fetchSkills = useMemo(() => _.debounce((inputValue, callback) => {
@@ -353,9 +353,9 @@ export default function GigApply(props) {
353353
<div styleName="error">
354354
<h3>You must be a Topcoder member to apply!</h3>
355355
<div styleName="cta-buttons">
356-
<Link to={`${config.URL.AUTH}/member?retUrl=${encodeURIComponent(retUrl)}`} styleName="primaryBtn">Login</Link>
356+
<Link to={`${config.URL.AUTH}/member?retUrl=${retUrl}`} styleName="primaryBtn">Login</Link>
357357
</div>
358-
<p styleName="regTxt">Not a member? Register <a href={`${config.URL.AUTH}/?retUrl=${encodeURIComponent(retUrl)}&mode=signUp&utm_source=gig_listing&regSource=gigs`}>here</a>.</p>
358+
<p styleName="regTxt">Not a member? Register <a href={`${config.URL.AUTH}/?retUrl=${retUrl}&mode=signUp&utm_source=gig_listing&regSource=gigs`}>here</a>.</p>
359359
</div>
360360
</div>
361361
</div>

src/shared/components/TopcoderHeader/Auth/index.jsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ export default function Auth({ column }) {
2828
className="tc-btn-sm tc-btn-default"
2929
href={`${config.URL.AUTH}/member?utm_source=community-app-main`}
3030
onClick={(event) => {
31-
const retUrl = encodeURIComponent(window.location.href);
31+
const retUrl = encodeURIComponent(`${window.location.origin}${window.location.pathname}`);
3232
window.location = `${config.URL.AUTH}/member?retUrl=${retUrl}&utm_source=community-app-main`;
3333
event.preventDefault();
3434
}}

src/shared/components/tc-communities/AccessDenied/index.jsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ export default function AccessDenied(props) {
5050
className="tc-btn-md tc-btn-primary"
5151
href={`${config.URL.AUTH}/member?utm_source=${communityId}`}
5252
onClick={(event) => {
53-
const retUrl = encodeURIComponent(window.location.href);
53+
const retUrl = encodeURIComponent(`${window.location.origin}${window.location.pathname}`);
5454
window.location = `${config.URL.AUTH}/member?retUrl=${retUrl}&utm_source=${communityId}`;
5555
event.preventDefault();
5656
}}

src/shared/components/tc-communities/Footer/index.jsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ function Footer({
5656
<button
5757
className={theme.btnRegister}
5858
onClick={() => {
59-
const url = encodeURIComponent(window.location.href);
59+
const url = encodeURIComponent(`${window.location.origin}${window.location.pathname}`);
6060
window.location = `${config.URL.AUTH}/member/registration?retUrl=${url}&utm_source=${communityId}`;
6161
}}
6262
type="button"
@@ -66,7 +66,7 @@ function Footer({
6666
<button
6767
className={theme.btnLogin}
6868
onClick={() => {
69-
const url = encodeURIComponent(window.location.href);
69+
const url = encodeURIComponent(`${window.location.origin}${window.location.pathname}`);
7070
window.location = `${config.URL.AUTH}/member?retUrl=${url}&utm_source=${communityId}`;
7171
}}
7272
type="button"

src/shared/components/tc-communities/Header/index.jsx

+3-3
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ function Header(props) {
172172
communityId === 'zurich' ? (
173173
<PrimaryButton
174174
onClick={() => {
175-
const returnUrl = encodeURIComponent(window.location.href);
175+
const returnUrl = encodeURIComponent(`${window.location.origin}${window.location.pathname}`);
176176
window.location = `${config.URL.AUTH}/sso-login/?retUrl=${returnUrl}&utm_source=${communityId}`;
177177
}}
178178
size="sm"
@@ -184,7 +184,7 @@ function Header(props) {
184184
) : (
185185
<Button
186186
onClick={() => {
187-
const url = encodeURIComponent(`${window.location.href}?join=${groupIds[0]}`);
187+
const url = encodeURIComponent(`${window.location.origin}${window.location.pathname}?join=${groupIds[0]}`);
188188
window.location = `${config.URL.AUTH}/member?retUrl=${url}&utm_source=${communityId}`;
189189
}}
190190
size="sm"
@@ -196,7 +196,7 @@ function Header(props) {
196196
{ hideJoinNow ? null : (
197197
<PrimaryButton
198198
onClick={() => {
199-
let url = encodeURIComponent(`${window.location.href}?join=${groupIds[0]}`);
199+
let url = encodeURIComponent(`${window.location.origin}${window.location.pathname}?join=${groupIds[0]}`);
200200
url = encodeURIComponent(`${config.URL.AUTH}/member?retUrl=${url}&utm_source=${communityId}`);
201201
url = encodeURIComponent(url);
202202
window.location = `${config.URL.AUTH}/member/registration?retUrl=${url}&utm_source=${communityId}`;

src/shared/containers/Dashboard/index.jsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ function SlashTCContainer(props) {
4242

4343
useEffect(() => {
4444
if (props.tokenV3 && !isTokenExpired(props.tokenV3)) return;
45-
let url = `retUrl=${encodeURIComponent(location.href)}`;
45+
let url = `retUrl=${encodeURIComponent(`${window.location.origin}${window.location.pathname}`)}`;
4646
url = `${config.URL.AUTH}/member?${url}&utm_source=community-app-home-page`;
4747
location.href = url;
4848
}, [props.tokenV3]);

src/shared/containers/challenge-detail/index.jsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -327,7 +327,7 @@ class ChallengeDetailPageContainer extends React.Component {
327327
} = this.props;
328328
if (!auth.tokenV3) {
329329
const utmSource = communityId || 'community-app-main';
330-
window.location.href = `${config.URL.AUTH}/member?retUrl=${encodeURIComponent(window.location.href)}&utm_source=${utmSource}&regSource=challenges`;
330+
window.location.href = `${config.URL.AUTH}/member?retUrl=${encodeURIComponent(`${window.location.origin}${window.location.pathname}`)}&utm_source=${utmSource}&regSource=challenges`;
331331
} else {
332332
// Show security reminder to all registrants
333333
this.setState({

src/shared/containers/tc-communities/Loader.jsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ class Loader extends React.Component {
4242
visitorGroups,
4343
} = this.props;
4444

45-
const returnUrl = encodeURIComponent(window.location.href);
45+
const returnUrl = encodeURIComponent(`${window.location.origin}${window.location.pathname}`);
4646

4747
if (!loadingMeta && (
4848
!meta /* || (Date.now() - meta.timestamp) > MAXAGE */

src/shared/utils/tc.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,7 @@ export async function getM2mToken() {
212212
*/
213213
export function goToLogin(utmSource = '') {
214214
if (isomorphy.isClientSide()) {
215-
const retUrl = encodeURIComponent(window.location.href);
215+
const retUrl = encodeURIComponent(`${window.location.origin}${window.location.pathname}`);
216216
window.location = `${config.URL.AUTH}/member?retUrl=${retUrl}&utm_source=${utmSource}`;
217217
}
218218
}

0 commit comments

Comments
 (0)