Trim size of details in crash reports properly.

This commit is contained in:
ccd0 2016-05-04 17:14:02 -07:00
parent 7fba20d113
commit 1eea12ff27
2 changed files with 9 additions and 8 deletions

View File

@ -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",

View File

@ -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('<span class="report-error"> [<a href="${url}" target="_blank">report</a>]</span>') %>
isThisPageLegit: ->