From e225a523386a7caddc056cfc1e15b531b79303cb Mon Sep 17 00:00:00 2001 From: Lakshya <152306273+iLakshya04@users.noreply.github.com> Date: Tue, 1 Dec 2026 11:37:57 +0530 Subject: [PATCH] Fix copyright cut off after name, company and obfuscated email A three-letter mixed-case word such as MiG was lexed as JUNK, which broke the name, company chain so the copyright and holder stopped at the name. Remove that rule, and lex parenthesized (at) and (dot) like at and dot so the obfuscated email is recognised and left out of the holder. Reference: https://github.com/aboutcode-org/scancode-toolkit/issues/5574 Signed-off-by: Lakshya <152306273+iLakshya04@users.noreply.github.com> --- CHANGELOG.rst | 5 +++++ src/cluecode/copyrights.py | 6 +++--- .../data/copyrights/miglayout_mig_infocom.txt | 10 ++++++++++ .../data/copyrights/miglayout_mig_infocom.txt.yml | 11 +++++++++++ 4 files changed, 29 insertions(+), 3 deletions(-) create mode 100644 tests/cluecode/data/copyrights/miglayout_mig_infocom.txt create mode 100644 tests/cluecode/data/copyrights/miglayout_mig_infocom.txt.yml diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 424ff476627..5ad209b7ba7 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -13,6 +13,11 @@ v33.0.0 - 2026-10-30 - Improve copyright detection for statements with parens or trailing "authors" +- Fix copyright and holder detection cut off when a holder list has a name + followed by a company such as "Mikael Grev, MiG InfoCom AB." and an + obfuscated email like "(foo (at) bar (dot) com)". + https://github.com/aboutcode-org/scancode-toolkit/issues/5574 + - Add experimental option for using cached results during scan time. When the ``--use-cached-results`` option is enabled in the ScanCode CLI, during scan time for a given Resource, we iterate through the active scanners and see if we diff --git a/src/cluecode/copyrights.py b/src/cluecode/copyrights.py index 29876084168..c1c7dc9ad37 100644 --- a/src/cluecode/copyrights.py +++ b/src/cluecode/copyrights.py @@ -1262,9 +1262,6 @@ def build_detection_from_node( # by PaX Team (r"PaX$", 'NN'), - # short mixed caps with trailing cap: ZoY - (r"[A-Z][a-z][A-Z]$", 'JUNK'), - (r'^Tokenizers?$', 'JUNK'), (r'^Analyzers?$', 'JUNK'), (r'^PostingsFormats?$', 'JUNK'), @@ -2118,6 +2115,7 @@ def build_detection_from_node( (r'^and/or$', 'CC'), (r'^&$', 'CC'), (r'^at$', 'CC'), + (r'^\(at\)$', 'CC'), (r'^et$', 'CC'), (r'^Et$', 'CC'), (r'^ET$', 'CC'), @@ -2371,6 +2369,8 @@ def build_detection_from_node( # dot in: fooo at bar dot com (r'^dot$', 'DOT'), + # obfuscated emails with parens: fooo (at) bar (dot) com + (r'^\(dot\)$', 'DOT'), # moment/moment is an odd name (r'moment/moment$', 'NAME'), diff --git a/tests/cluecode/data/copyrights/miglayout_mig_infocom.txt b/tests/cluecode/data/copyrights/miglayout_mig_infocom.txt new file mode 100644 index 00000000000..27e804005df --- /dev/null +++ b/tests/cluecode/data/copyrights/miglayout_mig_infocom.txt @@ -0,0 +1,10 @@ +/* + * License (BSD): + * ============== + * + * Copyright (c) 2004, Mikael Grev, MiG InfoCom AB. (miglayout (at) miginfocom (dot) com) + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + */ diff --git a/tests/cluecode/data/copyrights/miglayout_mig_infocom.txt.yml b/tests/cluecode/data/copyrights/miglayout_mig_infocom.txt.yml new file mode 100644 index 00000000000..9f9b61d31d7 --- /dev/null +++ b/tests/cluecode/data/copyrights/miglayout_mig_infocom.txt.yml @@ -0,0 +1,11 @@ +what: + - copyrights + - holders + - holders_summary +copyrights: + - Copyright (c) 2004, Mikael Grev, MiG InfoCom AB. (miglayout (at) miginfocom (dot) com) +holders: + - Mikael Grev, MiG InfoCom AB. +holders_summary: + - value: Mikael Grev, MiG InfoCom AB. + count: 1