Hotfix for browser bug

Some browsers crash when allowed to have extremely long options in a
dropdown. This change truncates the user-supplied field of patch set
descriptions to 500 chars to prevent these crashes.

Bug: Issue 5085
Change-Id: I1fa5df3badb4ceca90519dfcd89369376992c432
This commit is contained in:
Kasper Nilsson
2016-12-15 17:59:50 -08:00
parent 61d57760a0
commit 111a46fd78
4 changed files with 16 additions and 4 deletions

View File

@@ -305,7 +305,7 @@ limitations under the License.
[[patchNum.num]]
/
[[_computeLatestPatchNum(_allPatchSets)]]
[[patchNum.desc]]
[[_computePatchSetDescription(_change, patchNum.num)]]
</option>
</template>
</select>

View File

@@ -14,6 +14,9 @@
(function() {
'use strict';
// Maximum length for patch set descriptions.
var PATCH_DESC_MAX_LENGTH = 500;
Polymer({
is: 'gr-change-view',
@@ -839,7 +842,8 @@
_computePatchSetDescription: function(change, patchNum) {
var rev = this.getRevisionByPatchNum(change.revisions, patchNum);
return (rev && rev.description) ? rev.description : '';
return (rev && rev.description) ?
rev.description.substring(0, PATCH_DESC_MAX_LENGTH) : '';
},
_computeDescriptionPlaceholder: function(readOnly) {

View File

@@ -14,6 +14,9 @@
(function() {
'use strict';
// Maximum length for patch set descriptions.
var PATCH_DESC_MAX_LENGTH = 500;
var COMMIT_MESSAGE_PATH = '/COMMIT_MSG';
Polymer({
@@ -624,7 +627,8 @@
_computePatchSetDescription: function(revisions, patchNum) {
var rev = this.getRevisionByPatchNum(revisions, patchNum);
return (rev && rev.description) ? rev.description : '';
return (rev && rev.description) ?
rev.description.substring(0, PATCH_DESC_MAX_LENGTH) : '';
},
});
})();

View File

@@ -14,6 +14,9 @@
(function() {
'use strict';
// Maximum length for patch set descriptions.
var PATCH_DESC_MAX_LENGTH = 500;
Polymer({
is: 'gr-patch-range-select',
@@ -73,7 +76,8 @@
_computePatchSetDescription: function(revisions, patchNum) {
var rev = this.getRevisionByPatchNum(revisions, patchNum);
return (rev && rev.description) ? rev.description : '';
return (rev && rev.description) ?
rev.description.substring(0, PATCH_DESC_MAX_LENGTH) : '';
},
});
})();