From 8906f9803837874824482ecf346a1dd116d622a5 Mon Sep 17 00:00:00 2001 From: Petr Mironychev <9195189+Palm1r@users.noreply.github.com> Date: Fri, 4 Apr 2025 15:29:36 +0200 Subject: [PATCH] fix: Rework copyright searching (#158) --- context/DocumentContextReader.cpp | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/context/DocumentContextReader.cpp b/context/DocumentContextReader.cpp index 8140d00..1fb52f9 100644 --- a/context/DocumentContextReader.cpp +++ b/context/DocumentContextReader.cpp @@ -145,9 +145,24 @@ CopyrightInfo DocumentContextReader::findCopyright() QRegularExpressionMatch match = matchIterator.next(); QString matchedText = match.captured().toLower(); - if (matchedText.contains("copyright") || matchedText.contains("(C)") - || matchedText.contains("(c)") || matchedText.contains("©") - || getYearRegex().match(text).hasMatch() || getNameRegex().match(text).hasMatch()) { + bool hasCopyrightIndicator = matchedText.contains("copyright") + || matchedText.contains("(c)") || matchedText.contains("©") + || matchedText.contains("copr.") + || matchedText.contains("all rights reserved") + || matchedText.contains("proprietary") + || matchedText.contains("licensed under") + || matchedText.contains("license:") + || matchedText.contains("gpl") || matchedText.contains("lgpl") + || matchedText.contains("mit license") + || matchedText.contains("apache license") + || matchedText.contains("bsd license") + || matchedText.contains("mozilla public license") + || matchedText.contains("copyleft"); + + bool hasYear = getYearRegex().match(matchedText).hasMatch(); + bool hasName = getNameRegex().match(matchedText).hasMatch(); + + if ((hasCopyrightIndicator && (hasYear || hasName)) || (hasYear && hasName)) { int startPos = match.capturedStart(); int endPos = match.capturedEnd();