The current JS compression in D5 and D6 delete the copyright and license information. We should keep this intact (and move to the top) for not getting a law problem.

Here is an example with http://cssdoc.net/ that is based on javadoc standard that can be used to read this automatically and looks nearly the same like the currently used PHP inline documentation in Drupal.

/**
* @copyright    Copyright 2005-2007, Firstname Lastname
* @license        CC-A 2.0 (http://creativecommons.org/licenses/by/2.0/)
*/
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

hass’s picture

Component: javascript » base system
Wim Leers’s picture

Priority: Critical » Normal

Marking as non-critical.

hass’s picture

Title: JS compression delete license » JS aggregation delete license
Gábor Hojtsy’s picture

How would you identify a copyright comment? It is many times not in the @copyright form you use here. Look at the jquery comment for example.

Gábor Hojtsy’s picture

Status: Active » Postponed (maintainer needs more info)
hass’s picture

Status: Postponed (maintainer needs more info) » Active

The comments are currently not in this format - yes... but if the copyright information is required by law we are able to keep the information. i see no other way how it can be accomplished in a different way. We need to specify how comments this must look like and then we keep the notice intact (and move to the top). if someone adds normal inline comments in JS this comments will be removed as now. This is the expected behaviour for JS aggregation...

So i prefer to use the example as specification how this comments must looks like, while it is machine readable (what normal inline comments are not).

Gábor Hojtsy’s picture

How the copyright should look like is not specified by us, but the copyright holder, as in the case of the jquery copyright for example.

Frando’s picture

Either we just include the first phpdoc comment of all files in the aggregated version, or we define some custom marker, like [copyright], [/copyright], which the aggregation function then collects into a new comment at the beginning of the aggregated file. The latter is "more secure", of course, but would require to add these copyright tags to all copyrighted files, e.g. to jquery.js.

hass’s picture

nobody makes us to keep his comment 100% intact, isn't it? We are made to tell "the copyright owner is..." and "this is licensed under..." nothing more. So as an example for jquery may this ends with:

Original notice:

/*
 * jQuery 1.1.2 - New Wave Javascript
 *
 * Copyright (c) 2007 John Resig (jquery.com)
 * Dual licensed under the MIT (MIT-LICENSE.txt)
 * and GPL (GPL-LICENSE.txt) licenses.
 *
 */

Aggregateable jquery notices:

/**
* @copyright   2007 John Resig (jquery.com)
* @license       Dual licensed under the MIT (MIT-LICENSE.txt) and GPL (GPL-LICENSE.txt) licenses.
*/

The comment should be keept as short as possible by law. name the owner, name the license that's it. don't insert the full license... we'd like to compress code and not keep it as big as it is :-).

Gábor Hojtsy’s picture

What we are required to keep and what we are able to modify depends on the exact license text, not some gut feelings. As long as it is not strengthened by a license quote, it is not possible to modify the exact copyright text used by the originating authors.

hass’s picture

Sorry, i have no clue what you are thinking about... :-) I'm sure we cannot guaranty that this solution will solve all variants today and for future, but nearly "all" and i thought about GPL, LGPL, CC and other variants - will work in this way very well. Other licenses may have issues with Drupal in general or are not allowed together with Drupal and therefore are no real issue. Are you thinking about a 0.01% variant?

I have often seen compressed JS files and all what copyright owners demanded - was one line like Copyright 2005-2007, Firstname Lastname on top. No one have written, we need to include a complete license text!? They understand what the intention is with compressing JS and CSS and nevertheless feel happy that we use their scripts... I think it is a good idea and to keep an additional license string intact, but cannot remember any compressed script with such a line... if someone does not allow alteration/compression of the JS code we can disable compression and keep the original file intact... drupal_add_js() have such a option, isn't it?

How do you like to solve this problem if not in this way?

Gábor Hojtsy’s picture

OK, seems like I was not understandable. The issue comes down to this: does the GPL says that we should keep the original copyright notice as-is, and we should not modify it? Does it say that we can modify it if we want? Does it say nothing about this topic? (Drupal only allows GPL contributions).

keith.smith’s picture

From Drupal's LICENSE.txt:

  1. You may copy and distribute verbatim copies of the Program's
source code as you receive it, in any medium, provided that you
conspicuously and appropriately publish on each copy an appropriate
copyright notice and disclaimer of warranty; keep intact all the
notices that refer to this License and to the absence of any warranty;
and give any other recipients of the Program a copy of this License
along with the Program.

www.gnu.org has a FAQ (http://www.gnu.org/copyleft/gpl.html) that -- though I didn't see this specific question -- addresses similar issues. In it, the following notices are recommended:

To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively state the exclusion of warranty; and each file should have at least the “copyright” line and a pointer to where the full notice is found.

    <one line to give the program's name and a brief idea of what it does.>
    Copyright (C) <year>  <name of author>

    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.

This sentence, however, probably accurately describes the bare minimum of information necessary on each file:

It is safest to attach them to the start of each source file to most effectively state the exclusion of warranty; and each file should have at least the “copyright” line and a pointer to where the full notice is found.

This "barest minimum" is more or less what seems to be found on jquery.js:

/*
 * jQuery 1.1.3 - New Wave Javascript
 *
 * Copyright (c) 2007 John Resig (jquery.com)
 * Dual licensed under the MIT (MIT-LICENSE.txt)
 * and GPL (GPL-LICENSE.txt) licenses.
 *
 * $Date: 2007-07-01 08:54:38 -0400 (Sun, 01 Jul 2007) $
 * $Rev: 2200 $
 */

All that said, of course, bear in mind that I am not a lawyer, nor do I play one on tv.

Gábor Hojtsy’s picture

Title: JS aggregation delete license » JS and CSS aggregation deletes license information
Frando’s picture

This is not only about GPL, though. A custom theme might have a custom copyright notice (as e.g. bluebeach on drupal.org) that one would not want to lose due to compression. So, I think that having some tags in the original css/js files that the aggregator parses out would be the only way to accomplish this. The aggregator should then include the content from between these tags in a comment at the top of the aggregated stylesheet/script file.

Wim Leers’s picture

How about this: we list the aggregated JS/CSS files in the aggregated file itself, thereby mentioning that for specifics about licenses, you should look in those files (which are simply the originals).

hass’s picture

I'm not a lawer, but it looks like the copyright should be the minimum. If we'd like to provide more info, we add a small copyright notice or a link to the license... but i think it is not required to add such bug text like written in #13. Everybody knows if you reference "GPL" where the GPL is located and we don't need to write all this license text... other licenses are nearly the same. CC for e.g. provide Webpages with their licenses. As Developer you only need to construct a link to "your" CC license and everyone knows "open this link and you can read the appropriate license". Something wrong with this?

xqus’s picture

The point made by Wim is good, anybody that knows the GPL (and other licenses) that know if that is a good enough solution?

Wim Leers’s picture

@hass: isn't that what my sugestion does? "linking" to the location of the license?

sun’s picture

+1 for Wim's idea

hass’s picture

yup, sounds a reasonable way

xqus’s picture

Status: Active » Needs review
FileSize
3.3 KB

Here is a patch implementing what Wim suggested.

sun’s picture

Status: Needs review » Needs work

Please have a look on Drupal Coding Standards.

In short:

  • Rename $fileHeader to $file_header
  • Fix string concatenation and do not use double quotes unless needed
    • Example: Change " * ".$GLOBALS['base_url']."/".$file."\n"; to ' * '. $GLOBALS['base_url'] .'/'. $file ."\n";
xqus’s picture

FileSize
3.31 KB

Ok, here we go again. :)

sun’s picture

There are still wrong string concatenations and malformed indents:

+          // Add the url to the aggregated file.
+          $file_header .= ' * '.$GLOBALS['base_url'].'/'.$file."\n";
{...}
-    file_save_data($data, $csspath .'/'. $filename, FILE_EXISTS_REPLACE);
+    file_save_data($file_header.$data, $csspath .'/'. $filename, FILE_EXISTS_REPLACE);
{...}
-        $contents .= _drupal_compress_js(file_get_contents($path). ';');
+        $contents   .= _drupal_compress_js(file_get_contents($path). ';');

btw: String concatenation after file_get_contents($path) seemed to be wrong before and may be fixed herein, too.

Comments should always end with a dot.

+    // Close the comment that list the aggregated files
xqus’s picture

In the cases where there are a line break in the string, what is the Drupal way of doing it?

$file_header .= " * The below content is aggregated from the following files.\n";

or

$file_header .= ' * The below content is aggregated from the following files.'."\n";
sun’s picture

You can use double quotes here.
However, if you'd use single quotes, string concatenation should look like '...following files.' . "\n"; , meaning: insert a space in front of and behind the concatenation character if the preceding and following term is a string.

xqus’s picture

FileSize
3.23 KB

Sorry for my ignorance.
I have read about string concatenations in the Drupal Coding Standards 4 times now, and I think i got it. The first time i read it, I was rather tired. :)
The Coding Standards says to place a space after the dot if the following term is not a quote. I see "\n" as a quote, and therefor there is no space before it. If this applies to only single-quote quotes, there is a need for two more spaces in the patch.

The rest of the problems, I think I have managed to fix.

sun’s picture

Looks great - however, it seems you accidently inserted white-space after

-      if ($info['preprocess']) {
+      if ($info['preprocess']) {        

After this quick fix, change the status to patch needs review, please.

xqus’s picture

Status: Needs work » Needs review
FileSize
3.14 KB
sun’s picture

I'm sorry, it seems we overlooked these accidentally changes:

-  $data = '';
-
+  $data = '';  
+ 
{...}
-function drupal_build_js_cache($files, $filename) {
-  $contents = '';
-
+function drupal_build_js_cache($files, $filename) {  
+  $contents   = '';  
+  

However, patch applies correctly. Works as described. Changed a CSS file in the queue and reference list was successfully updated.

One more review and this is RTBC.

xqus’s picture

FileSize
2.85 KB

Fixed, along with some other small things.

hass’s picture

I tried this patch on a D5 with 2 hunks (js compression), what i expected, but it works :-). The size of file will not grow much, what's good. Should we backport this for D5.2, too?

xqus’s picture

FileSize
1.66 KB

Here is a patch for Drupal 5.

moshe weitzman’s picture

we distribute drupal with license information. i don't think we are obligated to put a license into every page we serve.

hass’s picture

@moshe weitzman: Don't forget Themes with CC licenses or other licenses.

Aside, why has someone added the GPL license information to the misc/jquery.js file for D6 if this is not required? Someone from outside cannot see the license of CC after JS or CSS is compressed and may grap the code without notice...

catch’s picture

Status: Needs review » Needs work

needs a re-roll.

hass’s picture

We shouldn't waste too much time and build this on top of http://drupal.org/node/113607.

xqus’s picture

Version: 6.x-dev » 7.x-dev

Is this still a issue, or something that should not be fixed?

hass’s picture

Still an issue.

xqus’s picture

Status: Needs work » Needs review
FileSize
2.8 KB

Reroll against HEAD.

lilou’s picture

Status: Needs review » Postponed (maintainer needs more info)

It seems that this bug is no longer active : without this patch, license is stored with optimize mode enabled :

http://localhost/drupal/7.x/sites/default/files/js/ba699c2d833da30af428e... :

/*
 * jQuery 1.2.6 - New Wave Javascript
 *
 * Copyright (c) 2008 John Resig (jquery.com)
 * Dual licensed under the MIT (MIT-LICENSE.txt)
 * and GPL (GPL-LICENSE.txt) licenses.
 *
 * $Date: 2008/06/12 19:49:10 $
 * $Rev: 5685 $
 */

Someone can confirm ?

lilou’s picture

Status: Postponed (maintainer needs more info) » Postponed

Mark as postponed until #119441: Compress JS aggregation reopen.

hass’s picture

Status: Postponed » Needs review

This is not the case for CSS.

lilou’s picture

So it's good for me :

/**
 * The below content is aggregated from the following files.
 * For licensing information please look in the original files.
 *
 * http://localhost/drupal/7.x/modules/node/node.css
 * http://localhost/drupal/7.x/modules/system/defaults.css
 * http://localhost/drupal/7.x/modules/system/system.css
 * http://localhost/drupal/7.x/modules/system/system-menus.css
 * http://localhost/drupal/7.x/modules/user/user.css
 * http://localhost/drupal/7.x/themes/garland/style.css
 */
.node-unpublished{background-color:#fff4f4;}.preview .node{background-color:#ffffea;} ...
hass’s picture

This looks nice.

Anonymous’s picture

Status: Needs review » Needs work

The last submitted patch failed testing.

Wim Leers’s picture

Version: 7.x-dev » 8.x-dev
Damien Tournoud’s picture

Version: 8.x-dev » 7.x-dev

Only feature requests and tasks can be assigned to D8 for now, because the Drupal 8 tree is not opened yet.

xqus’s picture

FileSize
289.32 KB

Re-roll to HEAD, just minor changes.

xqus’s picture

Status: Needs work » Needs review

Status: Needs review » Needs work

The last submitted patch, drupal_156124.patch, failed testing.

xqus’s picture

Ok, I need some e help here. Any ideas how to get this patch to not fail the color module tests. I guess it's the header in the CSS files that breaks the test.

nod_’s picture

Version: 7.x-dev » 8.x-dev
Issue tags: +JavaScript
mgifford’s picture

#50 is a bad patch. #41 is in the right format but in the latter there must have been some typo.

@xqus - Any idea what the minor changes were?

mgifford’s picture

Issue summary: View changes
Issue tags: +Needs reroll
Risse’s picture

Assigned: Unassigned » Risse
Issue tags: +drupalcampfi

I'll check this out.

Risse’s picture

Assigned: Risse » Unassigned
Issue tags: -drupalcampfi
Wim Leers’s picture

Status: Needs work » Closed (duplicate)

A patch that fixes this problem lives over at #2258313: Add license information to aggregated assets.