Commit 952bfb6e authored by Carsten  Rose's avatar Carsten Rose

Refs #9517: TypeAhead - escaping ':' ',' partly implemented.

parent 6a4a04e4
Pipeline #3322 passed with stages
in 3 minutes and 49 seconds
......@@ -1363,23 +1363,13 @@ abstract class AbstractBuildForm {
$attribute .= Support::doAttribute(DATA_TYPEAHEAD_TAG_DELIMITER, $kk);
$formElement[FE_INPUT_TYPE] = 'hidden';
// TAG handling expects the '$value' as a JSON string.
// Old, much to complicated
$kk = KeyValueStringParser::parse($value, ':', ',', KVP_IF_VALUE_EMPTY_COPY_KEY);
// Client: TAG handling expects the '$value' as a JSON string.
$kk = KeyValueStringParser::parse($value, PARAM_KEY_VALUE_DELIMITER, PARAM_LIST_DELIMITER, KVP_IF_VALUE_EMPTY_COPY_KEY);
$jj = '';
foreach ($kk as $arrKey => $arrValue) {
$jj .= ',' . json_encode(["key" => $arrKey, "value" => $arrValue]);
}
$value = '[' . substr($jj, 1) . ']';
// $tags = [
// ['value' => "Alabama", 'key' => "AL"],
// ['value' => "Alaska", 'key' => "AK"]
// ];
// $tagsSafeJson = htmlentities(json_encode($tags), ENT_QUOTES, 'UTF-8');
//
// $tags1=KeyValueStringParser::parse($value, ':', ',', KVP_IF_VALUE_EMPTY_COPY_KEY);
// $tags1SafeJson = htmlentities(json_encode($tags1), ENT_QUOTES, 'UTF-8');
}
}
......@@ -1460,6 +1450,7 @@ abstract class AbstractBuildForm {
}
$attribute .= HelperFormElement::getAttributeList($formElement, [FE_TYPE, 'size']);
$attribute .= Support::doAttribute('value', htmlentities($value), false);
// $attribute .= Support::doAttribute('value', htmlentities($value, ENT_QUOTES, 'UTF-8'), false);
}
$attribute .= HelperFormElement::getAttributeList($formElement, [FE_INPUT_AUTOCOMPLETE, 'autofocus', 'placeholder']);
......
......@@ -1741,6 +1741,9 @@ const QUESTION_INDEX_FLAG_MODAL = 5;
const PARAM_DELIMITER = '|';
const PARAM_TOKEN_DELIMITER = ':';
const PARAM_LIST_DELIMITER = ',';
const PARAM_KEY_VALUE_DELIMITER = ':';
const TOKEN_URL = 'u';
const TOKEN_MAIL = 'm';
const TOKEN_PAGE = 'p';
......
......@@ -41,7 +41,8 @@ class KeyValueStringParser {
*
* @return string
*/
public static function unparse(array $keyValueArray, $keyValueDelimiter = ":", $listDelimiter = ",") {
public static function unparse(array $keyValueArray, $keyValueDelimiter = PARAM_KEY_VALUE_DELIMITER, $listDelimiter = PARAM_LIST_DELIMITER, $flagEscape = false) {
array_walk($keyValueArray, function (&$value) {
if (!is_string($value) || $value === "" || strlen($value) === 1) {
return;
......@@ -54,6 +55,13 @@ class KeyValueStringParser {
$newKeyValuePairImploded = array();
foreach ($keyValueArray as $key => $value) {
if ($flagEscape) {
$key = str_replace($keyValueDelimiter, '\\' . $keyValueDelimiter, $key);
$key = str_replace($listDelimiter, '\\' . $listDelimiter, $key);
$value = str_replace($keyValueDelimiter, '\\' . $keyValueDelimiter, $value);
$value = str_replace($listDelimiter, '\\' . $listDelimiter, $value);
}
$newKeyValuePairImploded[] = trim($key) . $keyValueDelimiter . $value;
}
......
......@@ -304,7 +304,7 @@ class FillStoreForm {
$arrValue = $this->doValue($formElement, $formMode, $row['value']);
$arrTmp[$arrKey] = $arrValue;
}
$val = KeyValueStringParser::unparse($arrTmp);
$val = KeyValueStringParser::unparse($arrTmp, PARAM_KEY_VALUE_DELIMITER, PARAM_LIST_DELIMITER, true);
} else {
// Single Value
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment