-14

A recent blog post celebrated the fact that 40.6 million copies of 7.3 million posts were performed by users over a two week period. The author is on the marketing team and from a marketing perspective this seems a positive indication.

However, from a legal perspective, it is problematic. Every post on Stack Overflow is covered by a version of the CC-BY-SA license. Compliance with this license is required by the Terms of Service. Previous blog posts have made it clear that attribution is required.

Stack Overflow users have shown a lot of interest in how their content is licensed and explicitly made clear that attribution is important to them.

License compliance is serious, and copied code from Stack Overflow is banned from inclusion in Apache Software Foundation projects out of respect for the license granted by those of us who post code on the site. In contrast, the blog post makes only a single vague mention of licensing:

And of course, be aware that some code requires a certain license to use.

"Some code", indeed. How about mentioning that all code posted on Stack Overflow requires attribution1?

Since the post, and related commentary, indicates that Stack Exchange has the ability to interact with user copy/paste behavior, it would go a long way toward encouraging attribution by automatically including an attribution link when code is copied from this site. A web search using the keyword "Automated Link Attribution" uncovers a few candidates, and another is discussed in this Stack Overflow question.

Certainly copy-pasters can easily violate the license by deleting the attribution, but it seems much more likely that at least some of the 20 million users per week would be more encouraged to comply with the TOS and respect the license granted by those of us who contribute to the site.

1 Unless the author explicitly provides another license for their content.

9
  • 3
    FWIW, Creative Commons do not recommend using a CC-BY-SA license for software, as discussed at opensource.stackexchange.com/q/1717 In theory, any code samples on the network are considered to be a component of documentation; Stack Overflow is not a software distribution service, as such. In practice, a lot of code does get copied & pasted from the network...
    – PM 2Ring
    Apr 22, 2021 at 5:56
  • 5
    "it would go a long way toward encouraging attribution by automatically including an attribution link when code is copied from this site" -- Daniel Widdis, meta.stackoverflow.com/q/407016 The majority of time I'm copying text from a post to a comment. Like I did now. I think it becomes a little bit inconvenient.
    – VLAZ
    Apr 22, 2021 at 6:34
  • @VLAZ I appreciate the concerns about inconvenience, but failing to follow the TOS or observe licensing requirements because they are "inconvenient" isn't a particularly compelling argument. Apr 22, 2021 at 6:42
  • 2
    @DanielWiddis "because they are "inconvenient"" -- Daniel Widdis, meta.stackoverflow.com/q/407016 but what if they are unnecessary?
    – VLAZ
    Apr 22, 2021 at 6:45
  • I think reference should survive renaming. And account deletetion, comment deletion. But also must be accurate. Here the second reference link to a question. Not to the comment. Imo it should be https://meta.stackoverflow.com/questions/407016/should-stack-overflow-implement-automated-link-attribution-on-copy-paste#comment838739_407016
    – Self
    Apr 22, 2021 at 6:56
  • 2
    It breaks the human element. You don't only provide attribution so it is known who was responsible for the content being copied, you also do it to clearly show you're not a thief, you do it willingly and out of respect. You can't outsource the latter to a device. It'd be like a celebrity putting down autographs with a stamp.
    – Gimby
    Apr 22, 2021 at 9:00
  • I'd encourage SE devs to implement this for the next April Fool's and observe how "well" it will go :) Apr 22, 2021 at 11:30
  • 1
    Did you mean: Cite button?
    – Andrew T.
    Apr 22, 2021 at 11:55
  • @AndrewT. - no, literally a forced attribution on every copy, after all, they already have the framework (with, of course, "copied from Stack Overflow on <date> at <time>") :) If you addressed me that is. Apr 22, 2021 at 11:58

2 Answers 2

4

To complement Cerbrus's answer, I have to say that when we license our work to Stack Exchange on the terms of CC-by-SA license (version 4.0 at the time of this writing), the onus is on them to provide appropriate attribution, which they do (every history item, post, comment, etc is properly attributed).

However, when we copy something, the onus is on us to provide attribution where necessary. If we are working on a project it is our problem to make sure we do not violate any applicable license. You might argue that the proposed feature will help ensure the above, but as everywhere in our craft, the question is: what the tradeoffs are?

Firstly, this is bad for business given the Stack Overflow model (after all, we are not a photo stock where authors get royalties off the licensed work). If attribution is forced upon users, they will gradually move to content providers that do not do that.

Secondly, this treats users like people with profound intellectual disability (read: idiots) instead of trying to educate them about the importance of attribution and possible legal ramifications in case of commercial products and restrictive licenses in general.

Finally, the proposal assumes the code is copied from Stack Overflow only for use in projects, but that's not true: a lot of times the copied content is a terminal command (i.e. a particular GIT incantation). You are welcome to try the demo0 feature out and see how "convenient" it would be:

(() => {

  const makeLinePrompt = () => {
    const prompt = document.createElement("div");
    prompt.classList.add("terminal-prompt");
    prompt.textContent = "$";
    return prompt;
  };

  const makeLineInput = (editable = true) => {
    const input = document.createElement("div");
    input.classList.add("terminal-input");
    input.contentEditable = editable;
    return input;
  };

  const makeLine = (editable = true) => {
    const line = document.createElement("div");
    line.classList.add("terminal-line");
    line.append(
      makeLinePrompt(),
      makeLineInput(editable)
    );
    return line;
  };

  const clearTerminal = (terminal) => {
    const prevLines = terminal.querySelectorAll(".terminal-line");
    prevLines.forEach((line, idx) => {
      if (idx === prevLines.length - 1) return;
      line.remove();
    });
  };

  const getCurrLine = (terminal) => terminal.querySelector(".terminal-input:focus");

  const clearLine = (terminal) => {
    const currLine = getCurrLine(terminal);
    if (currLine) currLine.textContent = "";
  };

  const switchLineToReadonly = (line) => {
    const prompt = line.querySelector(".terminal-prompt");
    prompt && prompt.remove();
    const input = line.querySelector(".terminal-input");
    input.contentEditable = false;
    input.innerText = input.innerText.replace(/(?:\r?\n)+$/, "");
  };

  document.addEventListener("keydown", (event) => {
    const terminal = document.getElementById("terminal");

    const {
      key,
      ctrlKey,
      metaKey
    } = event;

    if (ctrlKey || metaKey) {
      const ctrlMap = {
        "L": clearTerminal,
        "U": clearLine
      };

      const action = ctrlMap[key.toUpperCase()];
      if (!action) return;

      event.preventDefault();

      action(terminal);
    }

  });

  document.addEventListener("keyup", ({
    target,
    currentTarget,
    key,
    ctrlKey,
    metaKey,
    shiftKey
  }) => {
    if (target === currentTarget) return;

    const terminal = document.getElementById("terminal");

    if (key === "Enter" && !shiftKey) {
      const prevLines = terminal.querySelectorAll(".terminal-line");
      prevLines.forEach(switchLineToReadonly);

      const line = makeLine();
      terminal.append(line);

      line.querySelector(".terminal-input").focus();
    }
  });

  document.addEventListener("copy", ({
    target,
    currentTarget,
    clipboardData,
  }) => {
    if (target === currentTarget || target.tagName.toUpperCase() !== "CODE") return;

    const text = document.getSelection().toString().trim();

    const now = new Date().toISOString();

    const attributed = `${text} by Oleg Valter on ${now}, CC BY-SA 4.0`;

    clipboardData.setData("text/plain", attributed);
    event.preventDefault();
  });

})();
* {
  box-sizing: border-box;
}

code {
  background-color: grey;
  color: white;
  border-radius: 2px;
  padding: 10px;
}

code::before {
  content: "$"
}

.terminal {
  padding: 10px;
  padding-bottom: 2px;
  background-color: black;
  color: white;
}

z .terminal-line {
  padding: 2px;
}

.terminal-prompt,
.terminal-input {
  display: inline-block;
  vertical-align: top;
  padding-bottom: 4px;
  font-family: 'Source Code Pro', sans-serif;
  line-height: 16px;
  font-size: 12px;
}

.terminal-prompt {
  width: 10px;
}

.terminal-input {
  outline: none !important;
  min-width: 1px;
}
<link rel="preconnect" href="https://fonts.gstatic.com">
<link href="https://fonts.googleapis.com/css2?family=Source+Code+Pro&display=swap" rel="stylesheet">

<code>
git rebase -i --empty=keep --keep-empty --allow-empty-message HEAD~5
</code>

<p>
  Copy the command above and paste in the terminal below:
</p>

<div id="terminal" class="terminal">
  <div class="terminal-line">
    <div class="terminal-prompt">$</div>
    <div class="terminal-input" contenteditable="true"></div>
  </div>
</div>


0 I didn't give the snippet much thought, so if there are issues, let me know

14

No thanks, that would be a massive nuisance.

You'd have to remove the link every time you copy something to your code, an answer or wherever.

Frankly, I find sites doing something like that to be rather obnoxious.

2
  • I find such things obnoxious as well. However, ignoring TOS and license requirements because they are a nuisance isn't a particularly compelling argument. Apr 22, 2021 at 6:43
  • 9
    It's not ignoring the TOS, though. I'm not required to provide attribution when pasting question contents to an answer or comment. SE can't know where I intend to paste, and can't format the attribution for the intended paste location.
    – Cerbrus
    Apr 22, 2021 at 6:48

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .