Before the change, profanity has shown
`TypeError: prof_pre_chat_message_display() missing 3 required positional arguments: 'barejid',
'resource', and 'message'`
error for received messages with incorrect encoding
instead of proper error handling for string convertion.
That is a temporary fix, correct fix probably would be
passing potentially problematic char* as `bytes` (using `y` instead of `s` format),
but this would require API changes and hence correction of plugins to
handle new input parameters properly (likely with "decode" function).
A bit hard to reproduce. You need to add a plugin with the following code
(or any other plugin with `prof_pre_chat_message_display` present, such as emoticons.py):
```python
def prof_pre_chat_message_display(barejid, resource, message):
return message
```
and then receive/send message with incorrectly encoded character, it can be any
invalid UTF8 symbol. You'll see error in console, errors don't represent actual
errors in plugins, but rather Profanity's shortcoming, though it make appear so
that the problem is in plugin.
Actual proper handling would likely be using `y` instead of `s` format
(see [reference](https://docs.python.org/3/c-api/arg.html#c.Py_BuildValue))
> s ([str](https://docs.python.org/3/library/stdtypes.html#str) or None) [const char *]
> Convert a null-terminated C string to a Python [str](https://docs.python.org/3/library/stdtypes.html#str)
object using 'utf-8' encoding. If the C string pointer is NULL, None is used.
to
> y ([bytes](https://docs.python.org/3/library/stdtypes.html#bytes)) [const char *]
> This converts a C string to a Python [bytes](https://docs.python.org/3/library/stdtypes.html#bytes)
> object. If the C string pointer is NULL, None is returned.
since there is a [problem](https://docs.python.org/3/c-api/arg.html) with `s`:
> s ([str](https://docs.python.org/3/library/stdtypes.html#str)) [const char *]
> Convert a Unicode object to a C pointer to a character string.
> A pointer to an existing string is stored in the character pointer variable whose address you pass.
> ... Unicode objects are converted to C strings using 'utf-8' encoding.
> **If this conversion fails**, a [UnicodeError](https://docs.python.org/3/library/exceptions.html#UnicodeError) is raised.
In python such problem can be handled using `errors='ignore'` in [bytes.decode](https://docs.python.org/3/library/stdtypes.html#bytes.decode) or in a more sophisticated manner, depending on needs and realization.
Return static tabmode as default,
separate previous change in `dynamic` mode.
Despite usefulness of the solution,
it was not approved to be a new default.
Vote (link below) amongst users to change default
has shown inconclusive result and it was not representative,
as it had low number of participants.
https://github.com/profanity-im/profanity/pull/1912#issuecomment-1816232546
This commit changes the current behaviour which displays always the first
tabs until `maxtabs` to display N tabs around the currently selected tab.
So if we are having a maxtab of 1 and the actively selected window is 2,
then 2 is displayed only.
So far we have only displayed `>` to indicate that there are more windows.
Since this PR shifts the range of tabs that are displayed we also add `<`
indicator now to indicate windows to the left of the currently displayed.
Fix https://github.com/profanity-im/profanity/issues/1283
Fix https://github.com/profanity-im/profanity/issues/1764
`/redraw` command allows resolve problem for usual users,
as well as developers.
Incredibly useful when debugging with something that
can trash out the output, like GDB.
Not to mention many asynchronous commands that can break the UI
at any point.
Let user print newline character using alt+enter keybind,
it allows great flexibility in communication,
now user will be able to write much better longer messages.
Ensure consistent invocation of `plugins_pre_chat_message_display`
for outgoing messages. Before the change, the function was not
called for sent messages upon sending, but only on fetching
sent messages from DB.
Fix https://github.com/profanity-im/profanity/issues/1917
Refactor function to enhance memory handling, addressing
temporary workaround introduced in 2e0adbd. Adjustments
ensure cleaner code and maintainability.
Part of the improvements suggested by @sjaeckel.
On some commands execution (like `/privacy logging X`
where X is any symbol/group of symbols)
FALSE is being returned.
Which main cycle understands as a signal to exit profanity.
The mistake is common since returns are often used by
developers to communicate success status.
First reported by @doctor in the Profanity MUC,
as exit on `/logging group color` command.
`/executable vcard_photo test`
Printed
`Invalid usage, see '/help card_photo' for details.`
So it used the subcommand instead of the command and lost one of the
letters as well.
This mistake got introduced in 60c197487.
Where we added helper functions for the various `/executable` functions.
Discovered by @H3rnand3zzz with correct solution.
Fix https://github.com/profanity-im/profanity/issues/1921
Disallow correcting historical MUC messages, as the XEP-308 requires.
Previous changes introduce problem with
"Illicit LMC attempt from conference@server/user for message from user"
During investigation it was revealed that XEP does not recommend support
of historical MUC messages correction.
```
When used in a Multi-User Chat (XEP-0045) context,
corrections must not be allowed (by the receiver)
for messages received before the sender joined the room -
particularly a full JID leaving the room
then rejoining and correcting a message SHOULD be disallowed,
as the entity behind the full JID in the MUC may have changed.
```
https://xmpp.org/extensions/xep-0308.html#rules
XEP details mentioned by @jubalh
Bug discovered and solution improved by @jaeckel
Enhance data consistency by updating the database to treat empty
strings as NULL values. This change simplifies queries and improves
overall database integrity.
**Please, backup your DB before performing any testing.**
Introduce new DB structure and DB migration mechanism.
Index `timestamp`, `to_jid`, `from_jid` columns to improve performance.
Add trigger for `replaced_by_db_id` calculation by DB on message insert.
Now LMC messages are interconnected with original messages,
this way we have fast access to last (hence correct) applicable edits,
as well as reference to the original message from any edit (in case of chained edits).
Change the way LMC messages are being displayed. Now we check if we
can replace a message from current buffer. If we don't have a message in
the buffer, it might've been lost, but we can still display it as a
new message.
Further information available here:
https://github.com/profanity-im/profanity/pull/1893https://github.com/profanity-im/profanity/issues/1899https://github.com/profanity-im/profanity/pull/1902
Refactor getting char, introduce get_show_char() to follow DRY principle.
In theory, performance might be negatively affected after this change.
Ideally get_show_char should be optimized in the future.
Commit to allow unicode support in omemo/pgp/otr chars misses
adding support to set correction character.
1f8b1eb740
Further fixing commit also misses adding support to set the unicode character,
it only adds ability to display unicode correction character in the settings.
5cf6ee15cf6ee1bc6d0b99b01891bc455a657bf022a72b0
Stop fetching message from DB when profanity reached start or end of the history
with the user. This allows to save resources on page up/down
when ceiling or bottom accordingly are reached.
Currently buffer is being redrawn on each DB fetch,
this causes a big waste of resources as on every page_up button click
we redraw 1200 messages (each message can be longer than 1 line),
commit will reduce buffer size to 200,
thus reducing amount of messages redrawn on each page up,
this is a temporary solution for a bigger problem.
Before aliases used spaces in their name,
now the alias part is being read only before the first space,
thus allowing execution of complex command with aliases.
Example (with plugin):
`/alias add echo "/system exec echo"`
will allow execution of
`/echo test`
as opposed to prior state when the Profanity will
search for alias "echo tests" and output `Unknown command: /echo test`
Minor change: removed an example with invalid command (`/away`)
`/plugins reload non-existent-plugin` printed:
```
Failed to reload plugin: non-existent-plugin, `:^C
```
There were two mistakes:
error_message instead of error_message->str was passed to cons_show().
And in case of failing to unload the plugin due to not finding it in the
hash table it didn't print an error.
This bug was introduced in cc697de05.
When we received a message correction via `XEP-0308: Last Message Correction`
we accepted the change without checking the sender
making it possible for anybody to replace the message if the ID was known.
This change has been proposed by @jubalh
https://github.com/profanity-im/profanity/pull/1893#issuecomment-1752434740
Add logging for cases when the message is not being inserted in the DB due to its ID.
Make diagnostic of unreliable message history much easier,
lay the groundwork for a fully reliable message history.
Further changes might include insertion of messages with non-unique stanza-id,
but as it's a big change with plentiful issues, decision was made
to further investigate potential causes of history unreliability.
For details see #1893 discussion
In some cases it was possible that the `roster_pending_presence` list was
not free'd correctly.
Signed-off-by: Steffen Jaeckel <jaeckel-floss@eyet-services.de>
Sometimes the server is too busy sending other stanzas or our connection is
saturated because of something else, so the pong arrives too late.
Prevent the autoping disconnect event by extending the timeout
each time a stanza is received.
Signed-off-by: Steffen Jaeckel <jaeckel-floss@eyet-services.de>
We have to lazy load the keyfiles as they will maybe be written at one
point and should be initialized by that time.
Fixup of ca2df180d8
Signed-off-by: Steffen Jaeckel <jaeckel-floss@eyet-services.de>
If `n` is the number of `substr` replace operations, the old
implementation did `n+1` allocations and always first copied start,
then replacement, then the remaining (unsearched) part of the original
string.
Now calculate the number of occurences of `substr` before allocating the
resulting string.
Change the algorithm to parse through the original string and only
copy the parts that must be kept into the resulting string plus the
replacements where they belong at.
Now we also only have to go through the original string twice plus we only
do a single allocation.
Signed-off-by: Steffen Jaeckel <jaeckel-floss@eyet-services.de>
Previously we printed a format string into a `GString` to then print that
result again into a `GString` and display that.
This patch removes one level of `GString` printing by forwarding the
`va_arg` to the newly added API `win_println_va()`.
Introducing `static win_println_va_internal()` also allowed refactoring
most of the `win_print*()` and `win_append*()` implementations and removing
all the redundant code.
Signed-off-by: Steffen Jaeckel <jaeckel-floss@eyet-services.de>
When we are not connected and run `/plugins install` we crash because we
get the account struct to check for the (xmpp) tls setting.
To apply that to the http (etc) connection to download the plugin from a
server.
This got introduced in 3a86b8c29 to fix#1624.
There are several ways to handle this (some described in 1880) in this
patch I took the route that it will use secure connection when we are
nto connected and will only check the tls.trust account setting if we
are connected.
Fix https://github.com/profanity-im/profanity/issues/1880
Thanks to @alarixnia fot the patch and bugreport.
```
Forwarding a bug reported using the NetBSD bug tracker ("Profanity crashes at login"): http://gnats.netbsd.org/57050
The code in question here handles messages by people not in the user's contact list, and what is probably happening is that the XMPP server is sending such a message before profanity has set up its window layout.
Setting roster.unsubscribed=false indeed makes profanity start without crashing, and the attached patch bails out early in the problematic code path if layout->subwin is NULL (Adrian verified for me that either of the two makes profanity work for him again). But I am not familiar enough with the profanity code to say if this has any issues.
Profanity compiled with ncurses doesn't crash because ncurses's wattron() has a guard against the user passing null pointers, but the X/Open curses library standard doesn't have this guarantee and there's no guard in the NetBSD curses implementation.
```
Fix https://github.com/profanity-im/profanity/issues/1769
Add ability to completely turn logs off,
Needed since `/logging` and `/history` didn't stop history logging
in the DB, only in files.
Command might break something on usage,
hence it was primarily introduced for privacy geeks.
Privacy command discussion #1836
Refactor `p_gpg_list_keys`
Add `/pgp autoimport` command,
it's not described in XEP-0027, but used in some clients,
such as PSI, Pidgin. It will autoimport keys received with
`/pgp sendpub`, in plain text as a message, or using features,
provided in other clients. It doesn't autoassign them, but shows
command to assign, letting user to decide.
Improve documentation for some preexisting functions
Add contact argument to `/pgp sendpub`
Improve documentation
Update code formatting and indentation for better readability
Show state if no argument provided
Show if argument wasn't changed
Reduce amount of arguments
Command allows to share your PGP pub key with ease,
it's not described in XEP-0027, but used in some clients,
such as PSI, Pidgin.
Fix typos
Minor improvements
The strings have to be dup'ed, otherwise we'll free them twice.
Fixes#1855
Introduced by b6bb50ceb2
Signed-off-by: Steffen Jaeckel <jaeckel-floss@eyet-services.de>
Tell the user that a MAM request will be issued delayed instead of showing
a warning that MAM isn't supported by the server.
Signed-off-by: Steffen Jaeckel <jaeckel-floss@eyet-services.de>