Skip to content
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import React from 'react';
import GroupEventDataSection from 'app/components/events/eventDataSection';
import SentryTypes from 'app/sentryTypes';
import RichHttpContent from 'app/components/events/interfaces/richHttpContent';
import {getCurlCommand} from 'app/components/events/interfaces/utils';
import {getFullUrl, getCurlCommand} from 'app/components/events/interfaces/utils';
import {isUrl} from 'app/utils';
import {t} from 'app/locale';
import ExternalLink from 'app/components/externalLink';
Expand Down Expand Up @@ -49,23 +49,13 @@ class RequestInterface extends React.Component {
let data = this.props.data;
let view = this.state.view;

let fullUrl = data.url;
let parsedUrl = null;
if (fullUrl) {
if (data.query) {
fullUrl += '?' + data.query;
}
if (data.fragment) {
fullUrl += '#' + data.fragment;
}

if (!isUrl(fullUrl)) {
// Check if the url passed in is a safe url to avoid XSS
fullUrl = null;
}
let fullUrl = getFullUrl(data);
if (!isUrl(fullUrl)) {
// Check if the url passed in is a safe url to avoid XSS
fullUrl = null;
}

// check `fullUrl` again because of `isUrl` check
let parsedUrl = null;
if (fullUrl) {
// use html tag to parse url, lol
parsedUrl = document.createElement('a');
Expand Down
39 changes: 29 additions & 10 deletions src/sentry/static/sentry/app/components/events/interfaces/utils.jsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {isString} from 'lodash';
import {isEmpty, isString} from 'lodash';
import * as Sentry from '@sentry/browser';
import queryString from 'query-string';

Expand Down Expand Up @@ -56,18 +56,37 @@ export function getCurlCommand(data) {
}
}

result += ' \\\n "' + data.url;
result += ' \\\n "' + getFullUrl(data) + '"';
return result;
}

if (defined(data.query) && data.query) {
let queryObj = {};
for (let [k, v] of data.query) {
queryObj[k] = v;
}
result += '?' + queryString.stringify(queryObj);
export function stringifyQueryList(query) {
if (isString(query)) {
return query;
}

result += '"';
return result;
let queryObj = {};
for (let [k, v] of query) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why do we not stringify query directly?

queryObj[k] = v;
}
return queryString.stringify(queryObj);
}

export function getFullUrl(data) {
let fullUrl = data && data.url;
if (!fullUrl) {
return fullUrl;
}

if (!isEmpty(data.query)) {
fullUrl += '?' + stringifyQueryList(data.query);
}

if (data.fragment) {
fullUrl += '#' + data.fragment;
}

return fullUrl;
}

/**
Expand Down