Skip to content

Commit 75a3ef7

Browse files
committed
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
1 parent 930e30e commit 75a3ef7

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

src/cluecode/copyrights.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4502,6 +4502,11 @@ def prepare_text_line(line):
45024502

45034503
# normalize copyright signs, quotes and spacing around them
45044504
.replace('"Copyright', '" Copyright')
4505+
4506+
# normalize [C] and [c] to (c) before bracket removal
4507+
.replace('[C]', '(c)')
4508+
.replace('[c]', '(c)')
4509+
45054510
.replace('( C)', ' (c) ')
45064511
.replace('(C)', ' (c) ')
45074512
.replace('(c)', ' (c) ')

tests/cluecode/test_copyrights_basic.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,16 @@ def test_prepare_text_line_does_not_damage_urls(self):
6868
result = prepare_text_line(cp)
6969
assert result == 'copyright (c) 2000 World Wide Web Consortium, http://www.w3.org'
7070

71+
def test_prepare_text_line_normalizes_bracket_C_uppercase(self):
72+
cp = '[C] The Regents of the University of Michigan and Merit Network, Inc. 1992, 1993, 1994, 1995 All Rights Reserved'
73+
result = prepare_text_line(cp)
74+
assert result == '(c) The Regents of the University of Michigan and Merit Network, Inc. 1992, 1993, 1994, 1995 All Rights Reserved'
75+
76+
def test_prepare_text_line_normalizes_bracket_c_lowercase(self):
77+
cp = 'Copyright [c] 2023 Example Company'
78+
result = prepare_text_line(cp)
79+
assert result == 'Copyright (c) 2023 Example Company'
80+
7181
def test_prepare_text_line_does_replace_copyright_signs(self):
7282
cp = 'Copyright \\A9 1991, 1999 Free Software Foundation, Inc.'
7383
result = prepare_text_line(cp)

0 commit comments

Comments
 (0)