Skip to content
This repository was archived by the owner on Aug 5, 2024. It is now read-only.

Commit 83379fc

Browse files
committed
Fix lineHash.hasOwnProperty might be contaminated
if calling method like dmp.diff_linesToChars_('hasOwnProperty', ' ') will throw TypeError: lineHash.hasOwnProperty is not a function since the lineHash is a instance of Object, the method can be overwritten while walking through the text lines. To avoid this, we can use Object.prototype.hasOwnProperty.call(lineHash, line) that make it always can call hasOwnProperty properly. Update diff_match_patch_uncompressed.js
1 parent 62f2e68 commit 83379fc

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

javascript/diff_match_patch_uncompressed.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -495,7 +495,7 @@ diff_match_patch.prototype.diff_linesToChars_ = function(text1, text2) {
495495
}
496496
var line = text.substring(lineStart, lineEnd + 1);
497497

498-
if (lineHash.hasOwnProperty ? lineHash.hasOwnProperty(line) :
498+
if (lineHash.hasOwnProperty ? Object.prototype.hasOwnProperty.call(lineHash, line) :
499499
(lineHash[line] !== undefined)) {
500500
chars += String.fromCharCode(lineHash[line]);
501501
} else {

0 commit comments

Comments
 (0)