Skip to content

Commit

Permalink
[bug 837112] Fix crash id linking
Browse files Browse the repository at this point in the history
  • Loading branch information
tobbi authored and rlr committed Feb 6, 2013
1 parent 35625f9 commit 424060a
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 4 deletions.
8 changes: 4 additions & 4 deletions media/js/questions.js
Expand Up @@ -210,15 +210,15 @@
if(!container) {
return;
}
var crashIDRegex = new RegExp("(bp-)?([a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12})", "g");
var crashIDRegex = new RegExp("([^{])(bp-[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12})([^}])", "g");
var crashStatsBase = "https://crash-stats.mozilla.com/report/index/";
var helpingWithCrashesArticle = "/kb/helping-crashes";
var iconPath = "/media/img/questions/icon.questionmark.png";
var crashReportContainer =
"<span class='crash-report'>" +
"$1<span class='crash-report'>" +
"<a href='" + crashStatsBase + "$2' target='_blank'>$2</a>" +
"<a href='" + helpingWithCrashesArticle + "' target='_blank'>" +
"<img src='" + iconPath + "'></img></a></span>";
"<img src='" + iconPath + "'></img></a></span>$3";

container.html(
container.html().replace(crashIDRegex,
Expand All @@ -232,7 +232,7 @@
* Initialize the automatic linking of crash IDs
*/
function initCrashIdLinking() {
var postContents = $("#answers .content, #question .content, #more-system-details");
var postContents = $(".question .main-content, .answer .main-content, #more-system-details");
postContents.each(function() {
linkCrashIds($(this));
});
Expand Down
18 changes: 18 additions & 0 deletions media/js/tests/crashidtests.js
Expand Up @@ -40,4 +40,22 @@ test('dont_link_invalid_crash_id', function() {
equals(numIds, 0);
});

test('dont_link_crash_id_in_brackets', function() {
var $sandbox = this.sandbox;
var numIds = 0;
var content = $sandbox.find('.content_4');
k.linkCrashIds(content);
numIds = content.find('.crash-report').length;
equals(numIds, 0);
});

test('dont_link_crash_id_without_bp', function() {
var $sandbox = this.sandbox;
var numIds = 0;
var content = $sandbox.find('.content_5');
k.linkCrashIds(content);
numIds = content.find('.crash-report').length;
equals(numIds, 0);
});

});
8 changes: 8 additions & 0 deletions templates/tests/qunit.html
Expand Up @@ -203,6 +203,14 @@ <h1>Firefox keeps crashing</h1>
<p>The following will look like an invalid crash ID that hasn't been processed yet:</p>
<p>765879E6-CFE7-43A7-BE93-B2F322E67649</p>
</section>
<section class="content_4">
<p>This is a crash ID in brackets, which should not be linked:</p>
<p>{bp-6ec83338-f37e-4ee1-aef4-0e66c2120808}</p>
</section>
<section class="content_5">
<p>Now, crash IDs without 'bp-' at the beginning shouldn't get linked either</p>
<p>6ec83338-f37e-4ee1-aef4-0e66c2120808</p>
</section>
</div>

<script src="{{ url('jsi18n') }}/build:{{ BUILD_ID_JS }}"></script>
Expand Down

0 comments on commit 424060a

Please sign in to comment.