Commit graph

13 commits

Author SHA1 Message Date
Vadim Peretokin
4d36d19274
fix: MXP text now shows correctly on non-English games (#9491)
#### Brief overview of PR changes/additions

MXP element attribute values - such as `SEND` link targets/hints and
`<!ENTITY>` values - were always decoded as UTF-8, ignoring the
session's negotiated encoding. On non-UTF-8 games (Latin1, GBK, Big5,
WINDOWS-1251, ...) any non-ASCII bytes in an attribute were mis-decoded,
so MXP links and entities carried garbled text.

This threads the active session encoding into `TMxpNodeBuilder` (set by
`TMxpProcessor` before parsing each character) and decodes attribute
names/values through a new shared `TStringUtils::decodeBytes` helper.
That helper also replaces the duplicated decode logic previously inline
in `TMxpProcessor::decodeRawBytes`, so the attribute path and the raw
tag/content path now interpret bytes identically. An empty
(not-yet-negotiated) encoding continues to be treated as UTF-8,
preserving prior behaviour for default sessions.

#### Motivation for adding to Mudlet

Players on non-English MUDs saw corrupted text in MXP links and custom
entities whenever those carried accented or non-Latin characters - the
attribute parser was the only MXP path still hardcoding UTF-8 while
element content already honoured the session encoding.

#### Other info (issues closed, discussion etc)

Added regression tests:
- `TMxpEntityTagHandlerTest`: quoted and unquoted `<!ENTITY>` values in
a WINDOWS-1251 session decode to "Гроза"; a UTF-8 session still resolves
the same value unchanged.
- `TMxpSendTagHandlerTest`: a `SEND href` with Latin1 bytes decodes to
"señor"; an empty (default) session encoding still decodes attributes as
UTF-8.

The WINDOWS-1251 entity test was verified to fail on the baseline
(producing U+FFFD replacement characters) before the fix. All 14
MXP/encoding/entity unit tests pass.

Assisted-by: Claude:claude-opus-4-8
2026-07-27 19:55:26 +02:00
Stephen Lyons
e72bcbf73c
Fix: Clazy warnings part 1A (more) - range-loop-detach (#9232)
#### Brief overview of PR changes/additions
One of a series of PRs, each addressing a type of issue reported by
Clazy.

This is some further: "C+11 range-loop might detach Qt container
[clazy-range-loop-detach]" type ones.

#### Motivation for adding to Mudlet
Remove warnings detected by the Clazy tool - either when explicitly run
on the Mudlet code-base or detected by the background scanner/analyser
that Qt Creator offers.

#### Other info (issues closed, discussion etc)
This is a supplement to PR #9195.

Signed-off-by: Stephen Lyons <slysven@virginmedia.com>
2026-04-25 21:17:42 +01:00
Mike Conley
fa0db506c1
Fix: Text with < characters disappearing on games with MXP enabled (#8918)
#### Brief overview of PR changes/additions

Fixes text containing `<` characters being swallowed when connecting to
games that negotiate MXP via telnet but don't actually send MXP content.

The fix validates text against the MXP specification to distinguish real
MXP tags from regular text, preventing false positives when `<` appears
in normal game text.

#### Motivation for adding to Mudlet

Users reported that typing commands like `echo <test` resulted in no
output on certain games (e.g., Merentha). The `<` character was being
interpreted as the start of an MXP tag, causing text to disappear.

#### Other info (issues closed, discussion etc)

Fixes #8899, #8980
2026-03-21 17:45:49 +00:00
Mike Conley
d0250979ce
Fix: MXP EXPIRE tag support and custom element attribute handling (#8431)
#### Brief overview of PR changes/additions

* **Add MXP EXPIRE tag support**: Implements the EXPIRE attribute for
MXP SEND tags, allowing servers to expire groups of links by name
* **Tooltip fix**: Fixed MXP link tooltips displaying "HREF" instead of
the actual link command when the EXPIRE attribute appears before the
HREF attribute in SEND tags
* **Custom element fix**: Fixed custom MXP elements to properly pass
through ALL attributes (EXPIRE, HREF, HINT, etc.) to their expanded tag
definitions

#### Motivation for adding to Mudlet

**EXPIRE tag support**: The MXP specification defines an EXPIRE
attribute that allows servers to tag groups of links and expire them all
at once (e.g., `<EXPIRE Exits>` expires all links tagged with
`EXPIRE="Exits"`). This is essential for dynamic content like room exits
that change as players move around.

**Tooltip fix**: Addresses reviewer feedback in PR #8383. When games
send MXP links like `<SEND EXPIRE="Exits" HREF="east">East</SEND>`, the
tooltip was incorrectly showing the literal text "HREF" instead of
"east" (the command that would be executed), making links confusing for
users.

**Custom element fix**: When servers define custom elements like
`<!ELEMENT Ex '<SEND>'>` and use them with attributes like `<Ex
EXPIRE="Exits" HREF="north">North</Ex>`, those attributes weren't being
passed through to the expanded SEND tag. This made custom elements less
functional than regular tags. Now all attributes are properly inherited.

#### Other info (issues closed, discussion etc)

- Related to PR #8383 (initial EXPIRE tag implementation discussion)
- Addresses @mfontani's comment about custom elements not passing
through EXPIRE attributes
- Added comprehensive unit tests:
  - Tooltip attribute ordering tests in `TMxpSendTagHandlerTest`
- Custom element attribute pass-through test in
`TMxpCustomElementTagHandlerTest`
- All existing MXP tests continue to pass (100% success rate)
- Changes summary: 5 files changed, 101 insertions(+), 2 deletions(-)
2025-10-26 20:48:42 +01:00
eowmob
2958e5c5e9
Improvement: Mxp entity & special character support in normal mud output (#6903)
<!-- Keep the title short & concise so anyone non-technical can
understand it,
     the title appears in PTB changelogs -->
#### Brief overview of PR changes/additions
Mudlet was only able to display entities with only one Latin1 character
in normal mud output.
This fix removes this restriction and also enables the use of special
characters represented by MXP default entities.
#### Motivation for adding to Mudlet
Improve MXP compliance
#### Other info (issues closed, discussion etc)
The patch changes small tidbits in several places: TBuffer was not able
to add additional characters to an input line, also the inserted entity
content must be reparsed to see if an MXP element is contained or to
interprete any non-Latin1 encoding while not risking a deadlock by
trying to resolve a recursive entity definition. This also required a
way for the entity resolver if a given entity is custom, default, or
unknown.

There are some screenshots and remarks at the end of
https://forums.mudlet.org/viewtopic.php?f=7&t=23206&start=10 .

Also, you can see how this works by connection to aldebaran-mud.de login
as a guest char (hit y to confirm) then "set mxp test 5", "set mxp test
6" or, for insights: "set mxp test 5 source", "set mxp test 6 source"
2024-08-31 15:33:24 +02:00
eowmob
fc204e0a3e
Improvement: MXP SEND menus can be extended with MXP entities (#6852)
<!-- Keep the title short & concise so anyone non-technical can
understand it,
     the title appears in PTB changelogs -->
#### Brief overview of PR changes/additions
MXP entities in send tags are interpolated before HREF and HINT lists
are split into part
#### Motivation for adding to Mudlet
Enhance MXP compatibility with other clients (like mushclient and cmud)
and MXP using muds.
#### Other info (issues closed, discussion etc)
To see the issue / change in action:

connect to aldebaran-mud.de port 2000
login as guest
y     (confirm you want to login as a guest)

Notice the mouse-over hint on the ... elipsis in the default prompt.
Right click and try some commands.

Now do:
alias bh ^BE HAPPY^bounce hap

Try entering 'bh' if you like. Do the mouse over again (in one of the
prompts printed after the alias cmd), right click
and try the "BE HAPPY" command from the menu.
2023-05-28 21:39:46 +02:00
Gustavo Sousa
48ce85fec2
Removes deprecated, unused code and fixes tests in TMxpParserTest (#4893)
- TMxpParserTest was testing functions that are never called and not testing the actual running code for some cases
- This commit changes the TMxpTagParser interface, unused functions and updates TMxpParserTest to test the actual code
2021-03-29 13:46:25 +02:00
Vadim Peretokin
3118f1275e
Revert "don't speak unless given text, ignore > and < (#4706)" (#4738)
This reverts commit faad4242e1.
2021-02-03 11:03:46 +01:00
Kebap
faad4242e1
don't speak unless given text, ignore > and < (#4706) 2021-02-02 10:14:12 +01:00
Gustavo Sousa
784cfc7b2e
Fix bug on parsing MXP tags with UTF8 strings (#4717) 2021-01-31 08:36:31 +01:00
Gustavo Sousa
46320c3135
Fixes #3900, bug on MXP SEND tags (#3908)
- Bug was caused by index out of range when processing MXP SEND tags with more commands than associated hints
- The solution uses HREF instead of HINT when the number of available hints is one and smaller than the number of commands
2020-06-15 21:49:00 +02:00
Gustavo Sousa
c63b59797e
Included test case for <send> tag example in issue #3723 (#3729)
* Included test case for `<send>` tag example in issue #3723

- Added a test case based on this issue to verify that it works correctly on new MXP implementation

* Fixes CodeFactor warning
2020-05-05 13:03:28 +02:00
Gustavo Sousa
102491a743
Refactoring/reimplementation of MXP support (#3625)
Refactoring/reimplementation of MXP protocol
        Extracts MXP support from TBuffer
        Separates input parsing from protocol processing: input is parsed into MxpTag objects by the MxpNodeBuilder and are passed to be handled by the MxpTagProcessor
        Class hierarchy of MxpTagHandler for implementing support for each tag: allows for a clear separation of the implementation of each tag and makes it easier for adding support for new tags
        Defines a clear interface (MxpClient) separating the MXP implementation from other parts of the code
        Solves some limitations of previous implementation such as supporting element definitions not only for<SEND> tags, interpolating named and positional attributes and interpolating &text; placeholder by tag content
        Includes support for COLOR tag
        Handles FONT, U, I, B, VAR and !ENTITY tags, but so far no defined behavior (can be implemented in MxpMudlet)
        Attributes that hold MXP state are now in the Host class to avoid needless copies when TBuffer is copied around
        Introduces QtTests for some of the classes
    Other refactorings intended to simplify TBuffer class, extracting responbilities that aren't directly related to the buffer mgmt
        Extracted TEncodingTable from TBuffer, this class is responsible for mapping encoding names to tables. It also removes some bloat from TBuffer.
        TLinkStore to manage links and associated hints to be displayed.
        TEntityResolver to map character entities, such as &gt; &#32; &#x20; to their associated string values; supports interpolating strings replacing the entity placeholders by their values
2020-05-03 19:09:42 +02:00