Skip to content

Commit

Permalink
webui: check the BZ report URL length before sending it
Browse files Browse the repository at this point in the history
  • Loading branch information
rvykydal committed Aug 28, 2023
1 parent 2f31233 commit 65925a9
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions ui/webui/src/components/Error.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,21 @@ export const bugzillaPrefiledReportURL = (productQueryData) => {
return reportURL.href;
};

const ensureMaximumReportURLLength = (reportURL) => {
const newUrl = new URL(reportURL);
const searchParamsLimits = [
{ param: "short_desc", length: 256, message: null },
{ param: "comment", length: 7800, message: "\nTHE COMMENT EXCEEDING THE LENGTH LIMIT WAS TRUNCATED" },
];
const sp = newUrl.searchParams;
searchParamsLimits.forEach((limit) => {
if (sp.get(limit.param)?.length > limit.length) {
sp.set(limit.param, sp.get(limit.param).slice(0, limit.length) + limit.message);
}
});
return newUrl.href;
};

const addLogAttachmentCommentToReportURL = (reportURL, logFile) => {
const newUrl = new URL(reportURL);
const comment = newUrl.searchParams.get("comment") || "";
Expand Down Expand Up @@ -83,6 +98,7 @@ export const BZReportModal = ({
}, []);

const openBZIssue = (reportURL, logFile, logContent) => {
reportURL = ensureMaximumReportURLLength(reportURL);
reportURL = addLogAttachmentCommentToReportURL(reportURL, logFile);
setPreparingReport(true);
cockpit
Expand Down

0 comments on commit 65925a9

Please sign in to comment.