From 5bcc04c9c38cf7210177d5811a900cf3433f6cd7 Mon Sep 17 00:00:00 2001 From: Shekhar Date: Fri, 21 Nov 2025 03:38:33 +0530 Subject: [PATCH] Fix #3659: Normalize [C] and [c] to (c) in copyright detection - Normalize [C] and [c] before bracket removal in prepare_text_line() - Add tests for both [C] and [c] variants Signed-off-by: Shekhar --- src/cluecode/copyrights.py | 5 +++++ tests/cluecode/test_copyrights_basic.py | 10 ++++++++++ 2 files changed, 15 insertions(+) diff --git a/src/cluecode/copyrights.py b/src/cluecode/copyrights.py index 8272135955f..3f3031a363e 100644 --- a/src/cluecode/copyrights.py +++ b/src/cluecode/copyrights.py @@ -4502,6 +4502,11 @@ def prepare_text_line(line): # normalize copyright signs, quotes and spacing around them .replace('"Copyright', '" Copyright') + + # normalize [C] and [c] to (c) before bracket removal + .replace('[C]', '(c)') + .replace('[c]', '(c)') + .replace('( C)', ' (c) ') .replace('(C)', ' (c) ') .replace('(c)', ' (c) ') diff --git a/tests/cluecode/test_copyrights_basic.py b/tests/cluecode/test_copyrights_basic.py index 23408ea643b..6e5dc8cf605 100644 --- a/tests/cluecode/test_copyrights_basic.py +++ b/tests/cluecode/test_copyrights_basic.py @@ -68,6 +68,16 @@ def test_prepare_text_line_does_not_damage_urls(self): result = prepare_text_line(cp) assert result == 'copyright (c) 2000 World Wide Web Consortium, http://www.w3.org' + def test_prepare_text_line_normalizes_bracket_C_uppercase(self): + cp = '[C] The Regents of the University of Michigan and Merit Network, Inc. 1992, 1993, 1994, 1995 All Rights Reserved' + result = prepare_text_line(cp) + assert result == '(c) The Regents of the University of Michigan and Merit Network, Inc. 1992, 1993, 1994, 1995 All Rights Reserved' + + def test_prepare_text_line_normalizes_bracket_c_lowercase(self): + cp = 'Copyright [c] 2023 Example Company' + result = prepare_text_line(cp) + assert result == 'Copyright (c) 2023 Example Company' + def test_prepare_text_line_does_replace_copyright_signs(self): cp = 'Copyright \\A9 1991, 1999 Free Software Foundation, Inc.' result = prepare_text_line(cp)