You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
(Feel free to resolve this as Won't Fix based on the limited set of potential strings that can be keys in a Unit dictionary. This is merely proof-of-concept for something that struck me as weird.)
The object_hash module uses the getSourceString function to turn a Unit into a String before hashing the String to produce a content_hash (among other things). The getSourceString function produces the same output String for different inputs, which, in turn, produces an identical hash. This is because the object type is not tokenized, and this could theoretically cause an issue as it breaks the widespread assumption that different inputs of the same data type (e.g., Unit) will hash to different values.
This example input:
var objectOne = ['s', 'a'];
var sourceStringOne = getSourceString(objectOne);
var objectTwo = [{s: {s: 'a'}}];
var sourceStringTwo = getSourceString(objectTwo);
console.log("Object One: " + sourceStringOne);
console.log("Object Two: " + sourceStringTwo);
console.log("Strings match? " + (sourceStringOne === sourceStringTwo));
produces this output (including unprintable characters):
(Feel free to resolve this as Won't Fix based on the limited set of potential strings that can be keys in a Unit dictionary. This is merely proof-of-concept for something that struck me as weird.)
The
object_hash
module uses thegetSourceString
function to turn a Unit into a String before hashing the String to produce a content_hash (among other things). ThegetSourceString
function produces the same output String for different inputs, which, in turn, produces an identical hash. This is because theobject
type is not tokenized, and this could theoretically cause an issue as it breaks the widespread assumption that different inputs of the same data type (e.g., Unit) will hash to different values.This example input:
produces this output (including unprintable characters):
Again, this case is extremely unlikely (maybe impossible) in this code base since the Unit object's keys are fixed, but I figured I'd call it out.
The text was updated successfully, but these errors were encountered: