ACE3/addons/common/functions/fnc_sanitizeString.sqf

54 lines
1.1 KiB
Plaintext
Raw Normal View History

#include "..\script_component.hpp"
/*
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 <STRING>
*
* Example:
* ["<CoolGroup>CoolGuy", true] call ace_common_fnc_sanitizeString;
2015-09-19 18:17:38 +00:00
*
* Public: Yes
*/
2015-09-19 18:17:38 +00:00
params ["_string", ["_removeTags", false]];
2015-05-14 18:06:06 +00:00
private _array = [];
{
switch _x do {
case 60 : { // less than symbol: `<`
2015-09-20 14:40:49 +00:00
if (_removeTags) then {
_array append toArray "&lt;";
} else {
_array pushBack _x;
};
};
case 62 : { // greater than symbol: `>`
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