Sun, 14 Jan 2024 20:08:13 -0600
Make sure all of the license headers for IRCv3 are GPLv2
Testing Done:
Ran `licensecheck` from debian in the following way.
```
$ licensecheck *.[ch] | cut -d: -f 2 | sort | uniq -c
27 GNU General Public License v2.0 or later
```
Reviewed at https://reviews.imfreedom.org/r/2913/
|
42505
cc095f9ce1f3
IRCv3: strip formatting from incoming messages
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
1 | /* |
|
cc095f9ce1f3
IRCv3: strip formatting from incoming messages
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
2 | * Purple - Internet Messaging Library |
|
cc095f9ce1f3
IRCv3: strip formatting from incoming messages
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
3 | * Copyright (C) Pidgin Developers <devel@pidgin.im> |
|
cc095f9ce1f3
IRCv3: strip formatting from incoming messages
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
4 | * |
|
42568
31e8c7c92e2f
Make sure all of the license headers for IRCv3 are GPLv2
Gary Kramlich <grim@reaperworld.com>
parents:
42505
diff
changeset
|
5 | * Purple is the legal property of its developers, whose names are too numerous |
|
31e8c7c92e2f
Make sure all of the license headers for IRCv3 are GPLv2
Gary Kramlich <grim@reaperworld.com>
parents:
42505
diff
changeset
|
6 | * to list here. Please refer to the COPYRIGHT file distributed with this |
|
31e8c7c92e2f
Make sure all of the license headers for IRCv3 are GPLv2
Gary Kramlich <grim@reaperworld.com>
parents:
42505
diff
changeset
|
7 | * source distribution. |
|
31e8c7c92e2f
Make sure all of the license headers for IRCv3 are GPLv2
Gary Kramlich <grim@reaperworld.com>
parents:
42505
diff
changeset
|
8 | * |
|
31e8c7c92e2f
Make sure all of the license headers for IRCv3 are GPLv2
Gary Kramlich <grim@reaperworld.com>
parents:
42505
diff
changeset
|
9 | * This library is free software; you can redistribute it and/or modify |
|
42505
cc095f9ce1f3
IRCv3: strip formatting from incoming messages
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
10 | * it under the terms of the GNU General Public License as published by |
|
cc095f9ce1f3
IRCv3: strip formatting from incoming messages
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
11 | * the Free Software Foundation; either version 2 of the License, or |
|
cc095f9ce1f3
IRCv3: strip formatting from incoming messages
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
12 | * (at your option) any later version. |
|
cc095f9ce1f3
IRCv3: strip formatting from incoming messages
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
13 | * |
|
42568
31e8c7c92e2f
Make sure all of the license headers for IRCv3 are GPLv2
Gary Kramlich <grim@reaperworld.com>
parents:
42505
diff
changeset
|
14 | * This library is distributed in the hope that it will be useful, |
|
42505
cc095f9ce1f3
IRCv3: strip formatting from incoming messages
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
cc095f9ce1f3
IRCv3: strip formatting from incoming messages
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
cc095f9ce1f3
IRCv3: strip formatting from incoming messages
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
17 | * GNU General Public License for more details. |
|
cc095f9ce1f3
IRCv3: strip formatting from incoming messages
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
18 | * |
|
cc095f9ce1f3
IRCv3: strip formatting from incoming messages
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
19 | * You should have received a copy of the GNU General Public License |
|
42568
31e8c7c92e2f
Make sure all of the license headers for IRCv3 are GPLv2
Gary Kramlich <grim@reaperworld.com>
parents:
42505
diff
changeset
|
20 | * along with this library; if not, see <https://www.gnu.org/licenses/>. |
|
42505
cc095f9ce1f3
IRCv3: strip formatting from incoming messages
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
21 | */ |
|
cc095f9ce1f3
IRCv3: strip formatting from incoming messages
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
22 | |
|
cc095f9ce1f3
IRCv3: strip formatting from incoming messages
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
23 | #include "purpleircv3formatting.h" |
|
cc095f9ce1f3
IRCv3: strip formatting from incoming messages
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
24 | |
|
cc095f9ce1f3
IRCv3: strip formatting from incoming messages
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
25 | #define IRCV3_FORMAT_BOLD (0x02) |
|
cc095f9ce1f3
IRCv3: strip formatting from incoming messages
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
26 | #define IRCV3_FORMAT_COLOR (0x03) |
|
cc095f9ce1f3
IRCv3: strip formatting from incoming messages
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
27 | #define IRCV3_FORMAT_HEX_COLOR (0x04) |
|
cc095f9ce1f3
IRCv3: strip formatting from incoming messages
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
28 | #define IRCV3_FORMAT_ITALIC (0x1d) |
|
cc095f9ce1f3
IRCv3: strip formatting from incoming messages
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
29 | #define IRCV3_FORMAT_MONOSPACE (0x11) |
|
cc095f9ce1f3
IRCv3: strip formatting from incoming messages
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
30 | #define IRCV3_FORMAT_RESET (0x0f) |
|
cc095f9ce1f3
IRCv3: strip formatting from incoming messages
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
31 | #define IRCV3_FORMAT_REVERSE (0x16) |
|
cc095f9ce1f3
IRCv3: strip formatting from incoming messages
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
32 | #define IRCV3_FORMAT_STRIKETHROUGH (0x1e) |
|
cc095f9ce1f3
IRCv3: strip formatting from incoming messages
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
33 | #define IRCV3_FORMAT_UNDERLINE (0x1f) |
|
cc095f9ce1f3
IRCv3: strip formatting from incoming messages
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
34 | |
|
cc095f9ce1f3
IRCv3: strip formatting from incoming messages
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
35 | /****************************************************************************** |
|
cc095f9ce1f3
IRCv3: strip formatting from incoming messages
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
36 | * Helpers |
|
cc095f9ce1f3
IRCv3: strip formatting from incoming messages
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
37 | *****************************************************************************/ |
|
cc095f9ce1f3
IRCv3: strip formatting from incoming messages
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
38 | static inline gboolean |
|
cc095f9ce1f3
IRCv3: strip formatting from incoming messages
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
39 | purple_ircv3_formatting_is_hex_color(const char *text) { |
|
cc095f9ce1f3
IRCv3: strip formatting from incoming messages
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
40 | for(int i = 0; i < 6; i++) { |
|
cc095f9ce1f3
IRCv3: strip formatting from incoming messages
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
41 | if(text[i] == '\0') { |
|
cc095f9ce1f3
IRCv3: strip formatting from incoming messages
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
42 | return FALSE; |
|
cc095f9ce1f3
IRCv3: strip formatting from incoming messages
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
43 | } |
|
cc095f9ce1f3
IRCv3: strip formatting from incoming messages
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
44 | |
|
cc095f9ce1f3
IRCv3: strip formatting from incoming messages
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
45 | if(!g_ascii_isxdigit(text[i])) { |
|
cc095f9ce1f3
IRCv3: strip formatting from incoming messages
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
46 | return FALSE; |
|
cc095f9ce1f3
IRCv3: strip formatting from incoming messages
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
47 | } |
|
cc095f9ce1f3
IRCv3: strip formatting from incoming messages
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
48 | } |
|
cc095f9ce1f3
IRCv3: strip formatting from incoming messages
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
49 | |
|
cc095f9ce1f3
IRCv3: strip formatting from incoming messages
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
50 | return TRUE; |
|
cc095f9ce1f3
IRCv3: strip formatting from incoming messages
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
51 | } |
|
cc095f9ce1f3
IRCv3: strip formatting from incoming messages
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
52 | |
|
cc095f9ce1f3
IRCv3: strip formatting from incoming messages
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
53 | /****************************************************************************** |
|
cc095f9ce1f3
IRCv3: strip formatting from incoming messages
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
54 | * Public API |
|
cc095f9ce1f3
IRCv3: strip formatting from incoming messages
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
55 | *****************************************************************************/ |
|
cc095f9ce1f3
IRCv3: strip formatting from incoming messages
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
56 | char * |
|
cc095f9ce1f3
IRCv3: strip formatting from incoming messages
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
57 | purple_ircv3_formatting_strip(const char *text) { |
|
cc095f9ce1f3
IRCv3: strip formatting from incoming messages
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
58 | GString *str = NULL; |
|
cc095f9ce1f3
IRCv3: strip formatting from incoming messages
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
59 | |
|
cc095f9ce1f3
IRCv3: strip formatting from incoming messages
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
60 | /* We don't use purple_strempty here because if we're passed an empty |
|
cc095f9ce1f3
IRCv3: strip formatting from incoming messages
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
61 | * string, we should return a newly allocated empty string. |
|
cc095f9ce1f3
IRCv3: strip formatting from incoming messages
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
62 | */ |
|
cc095f9ce1f3
IRCv3: strip formatting from incoming messages
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
63 | if(text == NULL) { |
|
cc095f9ce1f3
IRCv3: strip formatting from incoming messages
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
64 | return NULL; |
|
cc095f9ce1f3
IRCv3: strip formatting from incoming messages
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
65 | } |
|
cc095f9ce1f3
IRCv3: strip formatting from incoming messages
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
66 | |
|
cc095f9ce1f3
IRCv3: strip formatting from incoming messages
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
67 | str = g_string_new(""); |
|
cc095f9ce1f3
IRCv3: strip formatting from incoming messages
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
68 | |
|
cc095f9ce1f3
IRCv3: strip formatting from incoming messages
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
69 | for(int i = 0; text[i] != '\0'; i++) { |
|
cc095f9ce1f3
IRCv3: strip formatting from incoming messages
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
70 | switch(text[i]) { |
|
cc095f9ce1f3
IRCv3: strip formatting from incoming messages
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
71 | case IRCV3_FORMAT_BOLD: |
|
cc095f9ce1f3
IRCv3: strip formatting from incoming messages
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
72 | case IRCV3_FORMAT_ITALIC: |
|
cc095f9ce1f3
IRCv3: strip formatting from incoming messages
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
73 | case IRCV3_FORMAT_MONOSPACE: |
|
cc095f9ce1f3
IRCv3: strip formatting from incoming messages
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
74 | case IRCV3_FORMAT_RESET: |
|
cc095f9ce1f3
IRCv3: strip formatting from incoming messages
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
75 | case IRCV3_FORMAT_REVERSE: |
|
cc095f9ce1f3
IRCv3: strip formatting from incoming messages
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
76 | case IRCV3_FORMAT_STRIKETHROUGH: |
|
cc095f9ce1f3
IRCv3: strip formatting from incoming messages
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
77 | case IRCV3_FORMAT_UNDERLINE: |
|
cc095f9ce1f3
IRCv3: strip formatting from incoming messages
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
78 | continue; |
|
cc095f9ce1f3
IRCv3: strip formatting from incoming messages
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
79 | break; |
|
cc095f9ce1f3
IRCv3: strip formatting from incoming messages
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
80 | case IRCV3_FORMAT_COLOR: |
|
cc095f9ce1f3
IRCv3: strip formatting from incoming messages
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
81 | if(g_ascii_isdigit(text[i + 1])) { |
|
cc095f9ce1f3
IRCv3: strip formatting from incoming messages
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
82 | i += 1; |
|
cc095f9ce1f3
IRCv3: strip formatting from incoming messages
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
83 | |
|
cc095f9ce1f3
IRCv3: strip formatting from incoming messages
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
84 | if(g_ascii_isdigit(text[i + 1])) { |
|
cc095f9ce1f3
IRCv3: strip formatting from incoming messages
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
85 | i += 1; |
|
cc095f9ce1f3
IRCv3: strip formatting from incoming messages
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
86 | } |
|
cc095f9ce1f3
IRCv3: strip formatting from incoming messages
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
87 | |
|
cc095f9ce1f3
IRCv3: strip formatting from incoming messages
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
88 | if(text[i + 1] == ',' && g_ascii_isdigit(text[i + 2])) { |
|
cc095f9ce1f3
IRCv3: strip formatting from incoming messages
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
89 | i += 2; |
|
cc095f9ce1f3
IRCv3: strip formatting from incoming messages
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
90 | |
|
cc095f9ce1f3
IRCv3: strip formatting from incoming messages
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
91 | if(g_ascii_isdigit(text[i + 1])) { |
|
cc095f9ce1f3
IRCv3: strip formatting from incoming messages
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
92 | i += 1; |
|
cc095f9ce1f3
IRCv3: strip formatting from incoming messages
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
93 | } |
|
cc095f9ce1f3
IRCv3: strip formatting from incoming messages
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
94 | } |
|
cc095f9ce1f3
IRCv3: strip formatting from incoming messages
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
95 | } |
|
cc095f9ce1f3
IRCv3: strip formatting from incoming messages
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
96 | |
|
cc095f9ce1f3
IRCv3: strip formatting from incoming messages
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
97 | break; |
|
cc095f9ce1f3
IRCv3: strip formatting from incoming messages
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
98 | case IRCV3_FORMAT_HEX_COLOR: |
|
cc095f9ce1f3
IRCv3: strip formatting from incoming messages
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
99 | if(purple_ircv3_formatting_is_hex_color(&text[i + 1])) { |
|
cc095f9ce1f3
IRCv3: strip formatting from incoming messages
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
100 | i += 6; |
|
cc095f9ce1f3
IRCv3: strip formatting from incoming messages
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
101 | } |
|
cc095f9ce1f3
IRCv3: strip formatting from incoming messages
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
102 | |
|
cc095f9ce1f3
IRCv3: strip formatting from incoming messages
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
103 | if(text[i + 1] == ',' && |
|
cc095f9ce1f3
IRCv3: strip formatting from incoming messages
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
104 | purple_ircv3_formatting_is_hex_color(&text[i + 2])) |
|
cc095f9ce1f3
IRCv3: strip formatting from incoming messages
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
105 | { |
|
cc095f9ce1f3
IRCv3: strip formatting from incoming messages
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
106 | i += 7; |
|
cc095f9ce1f3
IRCv3: strip formatting from incoming messages
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
107 | } |
|
cc095f9ce1f3
IRCv3: strip formatting from incoming messages
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
108 | |
|
cc095f9ce1f3
IRCv3: strip formatting from incoming messages
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
109 | break; |
|
cc095f9ce1f3
IRCv3: strip formatting from incoming messages
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
110 | default: |
|
cc095f9ce1f3
IRCv3: strip formatting from incoming messages
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
111 | g_string_append_c(str, text[i]); |
|
cc095f9ce1f3
IRCv3: strip formatting from incoming messages
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
112 | break; |
|
cc095f9ce1f3
IRCv3: strip formatting from incoming messages
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
113 | } |
|
cc095f9ce1f3
IRCv3: strip formatting from incoming messages
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
114 | |
|
cc095f9ce1f3
IRCv3: strip formatting from incoming messages
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
115 | } |
|
cc095f9ce1f3
IRCv3: strip formatting from incoming messages
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
116 | |
|
cc095f9ce1f3
IRCv3: strip formatting from incoming messages
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
117 | return g_string_free(str, FALSE); |
|
cc095f9ce1f3
IRCv3: strip formatting from incoming messages
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
118 | } |