Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Chatbox spam by weird characters #557

Closed
ArranTuna opened this issue Sep 22, 2018 · 4 comments
Closed

Chatbox spam by weird characters #557

ArranTuna opened this issue Sep 22, 2018 · 4 comments
Labels
bug Something isn't working
Milestone

Comments

@ArranTuna
Copy link
Collaborator

Describe the bug
Recently some players found out how to spam -every- MTA chatbox with a weird symbol.

See the screenshot for an example.

To reproduce
Unknown as the mantis report did not contain the stated characters but the lua code below might help.

Expected behaviour

Screenshots
image

Version

Additional context
StuartUK:
This should remove allot of it they are most of the characters I found

function removeChatSpam(msg)
	local newMsg = ""
	for i = 1, utfLen(msg) do
		local char = utfCode(utfSub(msg,i,i))
		if(not (char >= 768 and char <= 879)) then
			newMsg = newMsg .. utfSub(msg,i,i)
		end
	end
	return newMsg
end

From https://bugs.mtasa.com/view.php?id=8114

@ArranTuna ArranTuna added the bug Something isn't working label Sep 22, 2018
@ArranTuna ArranTuna added this to the Backlog milestone Sep 22, 2018
@LosFaul
Copy link
Contributor

LosFaul commented Sep 23, 2018

This exists in endless other programs too and has something to do with special control characters.
So, it's more or less an issue of UTF-8/Unicode

@qaisjp
Copy link
Contributor

qaisjp commented Sep 23, 2018

I think it might be a good idea to include a fix for this in freeroam.

@Dutchman101
Copy link
Member

Dutchman101 commented Sep 23, 2018

I think it might be a good idea to include a fix for this in freeroam.

I doubt that freeroam is the only gamemode in official resources with its own chathandler..
Is there a particular reason for only suggesting freeroam?

Also, if you think fixing it in resources is the proper approach, then maybe we should add it regardless of official gamemode, which means we'd be adding chathandlers to any gamemode that does not have it.

@patrikjuvonen patrikjuvonen changed the title Chatbox spam by weird characters. Chatbox spam by weird characters Jan 3, 2019
qaisjp added a commit that referenced this issue Apr 23, 2019
Previously the render bounds for a singular chat line would be the
entire chat render bounds.

Now the render bounds for a singular chat line are:
- left: chat line x
- top: chat line y
- right: entire chat right
- bottom: chat line y + chat line height

Also fixes a minor off-by-one logical error in CChat::DrawTextString
relating to render boundaries.
@qaisjp
Copy link
Contributor

qaisjp commented Apr 23, 2019

Reproducible using: run outputChatBox("ą̷̳͎͚̫̱̼͚́̏͗́͋͆̆̋͋̑͛̅͗̀͌͐͒̓͋̋̅̑͒̔̉̓͒̀̃̊̒͌͆̆͐̒̂͒̄̉̂̆̾̋͋̊̂̈́̈́̈͘̚̕͘̚͘͝͝͝͝͝"). This is called "zalgo text".

My initial reasoning for fixing this in resources is that I don't think we shouldn't attempt to "fix" text with excessive diacritics as we cannot guarantee we are affecting legitimate use. A proper fix is to crop text rendering instead, as detailed below.


This can be fixed by ensuring CChatLineSection::Draw is passed an appropriate render boundary.

This issue can be hackily fixed by changing line 1120 of CChatLine::Draw from:

(*iter).Draw(..., RenderBounds);

to:

(*iter).Draw(..., CRect2D(vecPosition.fX, vecPosition.fY, RenderBounds.fY1, vecPosition.fY+13));

This is obviously not a suitable fix as 13 above should be CChat::GetDrawList fLineDifference... and the RenderBounds should be correct in the first place.

The RenderBounds is originally created in CChat::GetDrawList and passed through CChat::DrawDrawList.

Two options:

qaisjp added a commit that referenced this issue Apr 23, 2019
Previously the render bounds for a singular chat line would be the
entire chat render bounds.

Now the render bounds for a singular chat line are:
- left: chat line x
- top: chat line y
- right: entire chat right
- bottom: chat line y + chat line height

Also fixes a minor off-by-one logical error in CChat::DrawTextString
relating to render boundaries.
@qaisjp qaisjp closed this as completed in d514511 Apr 27, 2019
@patrikjuvonen patrikjuvonen modified the milestones: Backlog, 1.5.7 Apr 27, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

5 participants