• 
      

    Fix JS bug caused by UglifyJS+Backbone 1.6.1

    Review Request #14959 — Created March 25, 2026 and discarded — Latest diff uploaded

    Information

    Review Board
    release-7.x

    Reviewers

    Review Board 7.0.5 shipped with a bad bug which was causing review
    requests on the frontend to show up without any inline editor pencils.
    We hadn't hit this in development because it only affects the minified
    sources (and previous versions of Review Board shipped with older
    versions of Spina and thus older versions of Backbone).

    The core issue here is related to the way that UglifyJS collapses
    variables when not running in strict mode.

    In Backbone 1.6.1, the model constructor does something like this:

    var Model = function(attributes, options) {
        var attrs = attributes || {};
        if (options.parse) attrs = this.parse(attrs, options) || {};
        this.initialize.apply(this, arguments);
    };
    

    When running just like this, attrs and arguments are separate
    variables. However, after minification, it looks like this:

    function(e,t){
        var e=e||{};
        if(t.parse) e=this.parse(e,t)||{};
        this.initialize.apply(this,arguments);
    }
    

    In this, attrs and arguments are collapsed into a single variable
    e which gets reassigned when we call parse(), which changes the
    value of arguments[0]. When we then call this.initialize(), it's
    being called with the parsed data instead of the original attributes. If
    backbone was in strict mode, arguments would not be allowed to be
    aliased like this (and presumably uglify would do the right thing), but
    alas.

    In order to avoid hitting this, this change updates our ReviewablePage
    model in a couple ways:

    • parse() now passes through editorData so it's available in
      this.attributes after the parse operation.
    • initialize() now uses this.attributes instead of the attributes
      argument which gets munged by the constructor.

    Built and minified JS media and copied it into my RB 7.0.5 docker
    container. Verified that the fix works correctly.

    Review Board 7.1.x is not affected by this because we've switched
    to using Terser on that branch, which does not exhibit the same
    issue.

    Commits

    Files