ACE3/addons/common/functions/fnc_sanitizeString.sqf

52 lines
1.0 KiB
Plaintext
Raw Normal View History

/*
2015-03-24 04:18:00 +00:00
* Author: esteldunedain, based on Killzone-Kid code
* Removes quotation marks to avoid exploits and optionally html tags from text to avoid conflicts with structured text.
*
* Arguments:
2015-09-19 18:17:38 +00:00
* 0: Source string <STRING>
2015-09-20 14:40:49 +00:00
* 1: Remove html tags (default: false) <BOOL>
*
* Return Value:
* Sanitized string
2015-09-19 18:17:38 +00:00
*
* Public: Yes
*/
2015-01-13 19:56:02 +00:00
#include "script_component.hpp"
2015-09-19 18:17:38 +00:00
params ["_string", ["_removeTags", false]];
2015-05-14 18:06:06 +00:00
2015-09-20 14:40:49 +00:00
private "_array";
_array = [];
{
switch _x do {
case 60 : {
2015-09-20 14:40:49 +00:00
if (_removeTags) then {
_array append toArray "&lt;";
} else {
_array pushBack _x;
};
};
case 62 : {
2015-09-20 14:40:49 +00:00
if (_removeTags) then {
_array append toArray "&gt;";
} else {
_array pushBack _x;
};
};
2015-09-20 14:40:49 +00:00
case 34 : {
};
2015-09-20 14:40:49 +00:00
case 39 : {
};
2015-09-20 14:40:49 +00:00
default {
2015-09-20 14:40:49 +00:00
_array pushBack _x;
};
};
2015-09-19 18:17:38 +00:00
false
2015-09-20 14:40:49 +00:00
} count toArray _string;
2015-09-20 14:40:49 +00:00
toString _array // return