Skip to content

Commit

Permalink
Respect SOURCE_DATE_EPOCH spec
Browse files Browse the repository at this point in the history
 ckbuilder puts a buildtime timestamp both in comments and in other part of
 generated js. This patch make it observe SOURCE_DATE_EPOCH, so to allow for
 reproducible builds
 See https://reproducible-builds.org/specs/source-date-epoch/

Bug-Debian: https://bugs.debian.org/819726
Author: boyska <[email protected]>
Signed-off-by: Dmitry Smirnov <[email protected]>
  • Loading branch information
onlyjob committed Apr 4, 2016
1 parent b922d44 commit 9b82746
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
6 changes: 5 additions & 1 deletion src/ckbuilder.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,11 @@ this.CKBuilder = ( function() {
} catch ( e ) {
isMinified = false;
}
var now = new Date();
if(System.env.get('SOURCE_DATE_EPOCH') !== null) {
var now = new Date(parseInt(System.getenv("SOURCE_DATE_EPOCH"), 10) * 1000);
} else {
var now = new Date();
}
var timestamp = Integer.toString( now.getUTCFullYear() % 1000, 36 ) + Integer.toString( now.getUTCMonth(), 36 ) + Integer.toString( now.getUTCDate(), 36 ) + Integer.toString( now.getUTCHours(), 36 );
timestamp = timestamp.toUpperCase();

Expand Down
8 changes: 6 additions & 2 deletions src/lib/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,12 @@
* @static
*/
copyright: function( eol ) {
var copyright,
date = new Date();
var copyright;
if(System.env.get('SOURCE_DATE_EPOCH') !== null) {
var date = new Date(parseInt(System.getenv("SOURCE_DATE_EPOCH"), 10) * 1000);
} else {
var date = new Date();
}

if ( CKBuilder.options.commercial )
copyright = "/*" + eol + "This software is covered by CKEditor Commercial License. Usage without proper license is prohibited." + eol + "Copyright (c) 2003-" + date.getFullYear() + ", CKSource - Frederico Knabben. All rights reserved." + eol + "*/" + eol;
Expand Down

0 comments on commit 9b82746

Please sign in to comment.