From 1eea12ff271afa1601045c73af82ce4e6813b31b Mon Sep 17 00:00:00 2001 From: ccd0 Date: Wed, 4 May 2016 17:14:02 -0700 Subject: [PATCH] Trim size of details in crash reports properly. --- package.json | 2 +- src/main/Main.coffee | 15 ++++++++------- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/package.json b/package.json index de09daea0..668312b72 100644 --- a/package.json +++ b/package.json @@ -13,7 +13,7 @@ "changelog": "https://github.com/ccd0/4chan-x/blob/master/CHANGELOG.md", "issues": "https://gitreports.com/issue/ccd0/4chan-x", "newIssue": "https://gitreports.com/issue/ccd0/4chan-x?issue_title=%title&details=%details", - "newIssueMaxLength": 8200, + "newIssueMaxLength": 8181, "appid": "lacclbnghgdicfifcamcmcnilckjamag", "chromeStoreID": "ohnjgmpcibpbafdlkimncjhflgedgpam", "recaptchaKey": "6Ldp2bsSAAAAAAJ5uyx_lx34lJeEpTLVkP5k04qc", diff --git a/src/main/Main.coffee b/src/main/Main.coffee index f33ab316e..cf387821b 100644 --- a/src/main/Main.coffee +++ b/src/main/Main.coffee @@ -372,21 +372,22 @@ Main = data = errors[0] title = data.message title += " (+#{errors.length - 1} other errors)" if errors.length > 1 - details = """ + details = '' + addDetails = (text) -> + unless encodeURIComponent(title + details + text + '\n').length > <%= meta.newIssueMaxLength - meta.newIssue.replace(/%(title|details)/, '').length %> + details += text + '\n' + addDetails """ [Please describe the steps needed to reproduce this error.] Script: <%= meta.name %> <%= meta.fork %> v#{g.VERSION} #{$.platform} User agent: #{navigator.userAgent} URL: #{location.href} - - #{data.error} - #{data.error.stack?.replace(data.error.toString(), '').trim() or ''} """ - details += "\n\n#{data.html}" if data.html + addDetails '\n' + data.error + addDetails data.error.stack.replace(data.error.toString(), '').trim() if data.error.stack + addDetails '\n' + data.html if data.html details = details.replace /file:\/{3}.+\//g, '' # Remove local file paths - details = details.trim() url = "<%= meta.newIssue.replace('%title', '#{encodeURIComponent title}').replace('%details', '#{encodeURIComponent details}') %>" - url = url[...<%= meta.newIssueMaxLength %>] <%= html(' [report]') %> isThisPageLegit: ->