Cutelee  6.1.0
stringfilters.cpp
1 /*
2  This file is part of the Cutelee template system.
3 
4  Copyright (c) 2009,2010 Stephen Kelly <steveire@gmail.com>
5 
6  This library is free software; you can redistribute it and/or
7  modify it under the terms of the GNU Lesser General Public
8  License as published by the Free Software Foundation; either version
9  2.1 of the Licence, or (at your option) any later version.
10 
11  This library is distributed in the hope that it will be useful,
12  but WITHOUT ANY WARRANTY; without even the implied warranty of
13  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14  Lesser General Public License for more details.
15 
16  You should have received a copy of the GNU Lesser General Public
17  License along with this library. If not, see <http://www.gnu.org/licenses/>.
18 
19 */
20 
21 #include "stringfilters.h"
22 
23 #include "util.h"
24 
25 #include <QtCore/QRegularExpression>
26 #include <QtCore/QVariant>
27 #include <QtCore/QJsonArray>
28 #include <QtCore/QJsonObject>
29 #include <QtCore/QJsonDocument>
30 
32  const QVariant &argument,
33  bool autoescape) const
34 {
35  Q_UNUSED(argument)
36  Q_UNUSED(autoescape)
37  auto safeString = getSafeString(input);
38  safeString.get()
39  .replace(QLatin1Char('\\'), QStringLiteral("\\\\"))
40  .get()
41  .replace(QLatin1Char('\"'), QStringLiteral("\\\""))
42  .get()
43  .replace(QLatin1Char('\''), QStringLiteral("\\\'"));
44  return safeString;
45 }
46 
48  const QVariant &argument,
49  bool autoescape) const
50 {
51  Q_UNUSED(argument)
52  Q_UNUSED(autoescape)
53  auto safeString = getSafeString(input);
54  if (safeString.get().isEmpty())
55  return QString();
56 
57  return QVariant(safeString.get().at(0).toUpper()
58  + static_cast<QString>(
59  safeString.get().right(safeString.get().size() - 1)));
60 }
61 
62 EscapeJsFilter::EscapeJsFilter() {}
63 
64 static QList<std::pair<QString, QString>> getJsEscapes()
65 {
66  QList<std::pair<QString, QString>> jsEscapes;
67  jsEscapes << std::pair<QString, QString>(QChar::fromLatin1('\\'),
68  QStringLiteral("\\u005C"))
69  << std::pair<QString, QString>(QChar::fromLatin1('\''),
70  QStringLiteral("\\u0027"))
71  << std::pair<QString, QString>(QChar::fromLatin1('\"'),
72  QStringLiteral("\\u0022"))
73  << std::pair<QString, QString>(QChar::fromLatin1('>'),
74  QStringLiteral("\\u003E"))
75  << std::pair<QString, QString>(QChar::fromLatin1('<'),
76  QStringLiteral("\\u003C"))
77  << std::pair<QString, QString>(QChar::fromLatin1('&'),
78  QStringLiteral("\\u0026"))
79  << std::pair<QString, QString>(QChar::fromLatin1('='),
80  QStringLiteral("\\u003D"))
81  << std::pair<QString, QString>(QChar::fromLatin1('-'),
82  QStringLiteral("\\u002D"))
83  << std::pair<QString, QString>(QChar::fromLatin1(';'),
84  QStringLiteral("\\u003B"))
85  << std::pair<QString, QString>(QChar(0x2028), QStringLiteral("\\u2028"))
86  << std::pair<QString, QString>(QChar(0x2029),
87  QStringLiteral("\\u2029"));
88 
89  for (auto i = 0; i < 32; ++i) {
90  jsEscapes << std::pair<QString, QString>(
91  QChar(i),
92  QStringLiteral("\\u00")
93  + QStringLiteral("%1").arg(i, 2, 16, QLatin1Char('0')).toUpper());
94  }
95  return jsEscapes;
96 }
97 
99  const QVariant &argument,
100  bool autoescape) const
101 {
102  Q_UNUSED(argument)
103  Q_UNUSED(autoescape)
104  QString retString = getSafeString(input);
105 
106  static const auto jsEscapes = getJsEscapes();
107 
108  for (auto &escape : jsEscapes) {
109  retString = retString.replace(escape.first, escape.second);
110  }
111  return retString;
112 }
113 
115  const QVariant &argument,
116  bool autoescape) const
117 {
118  Q_UNUSED(argument)
119  Q_UNUSED(autoescape)
120  auto safeString = getSafeString(input);
121 
122  const QRegularExpression fixAmpersandsRegexp(
123  QStringLiteral("&(?!(\\w+|#\\d+);)"));
124 
125  safeString.get().replace(fixAmpersandsRegexp, QStringLiteral("&amp;"));
126 
127  return safeString;
128 }
129 
130 QVariant CutFilter::doFilter(const QVariant &input, const QVariant &argument,
131  bool autoescape) const
132 {
133  Q_UNUSED(autoescape)
134  auto retString = getSafeString(input);
135  auto argString = getSafeString(argument);
136 
137  auto inputSafe = retString.isSafe();
138 
139  retString.get().remove(argString);
140 
141  if (inputSafe && argString.get() != QChar::fromLatin1(';'))
142  return SafeString(retString, true);
143  else
144  return retString;
145 }
146 
147 QVariant SafeFilter::doFilter(const QVariant &input, const QVariant &argument,
148  bool autoescape) const
149 {
150  Q_UNUSED(argument)
151  Q_UNUSED(autoescape)
152  return markSafe(getSafeString(input));
153 }
154 
156  const QVariant &argument,
157  bool autoescape) const
158 {
159  Q_UNUSED(argument)
160  auto safeString = getSafeString(input);
161  auto lines = safeString.get().split(QLatin1Char('\n'));
162  auto width = QString::number(lines.size()).size();
163 
164  const auto shouldEscape = (autoescape && !safeString.isSafe());
165  for (auto i = 0; i < lines.size(); ++i) {
166  lines[i]
167  = QStringLiteral("%1. %2")
168  .arg(i + 1, width)
169  .arg(shouldEscape ? QString(escape(lines.at(i))) : lines.at(i));
170  }
171 
172  return SafeString(lines.join(QChar::fromLatin1('\n')), true);
173 }
174 
175 QVariant LowerFilter::doFilter(const QVariant &input, const QVariant &argument,
176  bool autoescape) const
177 {
178  Q_UNUSED(argument)
179  Q_UNUSED(autoescape)
180  return getSafeString(input).get().toLower();
181 }
182 
184  const QVariant &argument,
185  bool autoescape) const
186 {
187  Q_UNUSED(autoescape)
188  SafeString a;
189  if (isSafeString(input))
190  a = getSafeString(input);
191  else if (input.userType() == qMetaTypeId<QVariantList>()) {
192  a = toString(input.value<QVariantList>());
193  }
194 
195  return SafeString(getSafeString(argument).get().arg(a),
196  getSafeString(input).isSafe());
197 }
198 
199 QVariant TitleFilter::doFilter(const QVariant &input, const QVariant &argument,
200  bool autoescape) const
201 {
202  Q_UNUSED(argument)
203  Q_UNUSED(autoescape)
204 
205  QString str = getSafeString(input);
206 
207  auto it = str.begin();
208  const auto end = str.end();
209 
210  auto toUpper = true;
211  for (; it != end; ++it) {
212  if (toUpper)
213  *it = it->toUpper();
214  else
215  *it = it->toLower();
216  toUpper = it->isSpace();
217  }
218 
219  return str;
220 }
221 
223  const QVariant &argument,
224  bool autoescape) const
225 {
226  Q_UNUSED(autoescape)
227  auto s = getSafeString(argument);
228 
229  bool ok;
230  auto numWords = s.get().toInt(&ok);
231 
232  if (!ok) {
233  return input.toString();
234  }
235 
236  QString inputString = getSafeString(input);
237 #if QT_VERSION < QT_VERSION_CHECK(5, 14, 0)
238  auto words = inputString.split(QLatin1Char(' '), QString::SkipEmptyParts);
239 #else
240  auto words = inputString.split(QLatin1Char(' '), Qt::SkipEmptyParts);
241 #endif
242 
243  if (words.size() > numWords) {
244  words = words.mid(0, numWords);
245  if (!words.at(words.size() - 1).endsWith(QStringLiteral("..."))) {
246  words << QStringLiteral("...");
247  }
248  }
249  return words.join(QChar::fromLatin1(' '));
250 }
251 
252 QVariant UpperFilter::doFilter(const QVariant &input, const QVariant &argument,
253  bool autoescape) const
254 {
255  Q_UNUSED(argument)
256  Q_UNUSED(autoescape)
257  return getSafeString(input).get().toUpper();
258 }
259 
261  const QVariant &argument,
262  bool autoescape) const
263 {
264  Q_UNUSED(argument)
265  Q_UNUSED(autoescape)
266  return QString::number(
267  getSafeString(input).get().split(QLatin1Char(' ')).size());
268 }
269 
270 QVariant LJustFilter::doFilter(const QVariant &input, const QVariant &argument,
271  bool autoescape) const
272 {
273  Q_UNUSED(autoescape)
274  return getSafeString(input).get().leftJustified(
275  getSafeString(argument).get().toInt());
276 }
277 
278 QVariant RJustFilter::doFilter(const QVariant &input, const QVariant &argument,
279  bool autoescape) const
280 {
281  Q_UNUSED(autoescape)
282  return getSafeString(input).get().rightJustified(
283  getSafeString(argument).get().toInt());
284 }
285 
286 QVariant CenterFilter::doFilter(const QVariant &input, const QVariant &argument,
287  bool autoescape) const
288 {
289  Q_UNUSED(autoescape)
290  QString value = getSafeString(input);
291  const auto valueWidth = value.size();
292  const auto width = getSafeString(argument).get().toInt();
293  const auto totalPadding = width - valueWidth;
294  const auto rightPadding = totalPadding >> 1;
295 
296  return value.leftJustified(valueWidth + rightPadding).rightJustified(width);
297 }
298 
299 QVariant EscapeFilter::doFilter(const QVariant &input, const QVariant &argument,
300  bool autoescape) const
301 {
302  Q_UNUSED(argument)
303  Q_UNUSED(autoescape)
304  return markForEscaping(getSafeString(input));
305 }
306 
308  const QVariant &argument,
309  bool autoescape) const
310 {
311  Q_UNUSED(argument)
312  Q_UNUSED(autoescape)
313  return markSafe(escape(getSafeString(input)));
314 }
315 
317  const QVariant &argument,
318  bool autoescape) const
319 {
320  Q_UNUSED(autoescape)
321  const auto tags = getSafeString(argument).get().split(QLatin1Char(' '));
322  const auto tagRe
323  = QStringLiteral("(%1)").arg(tags.join(QChar::fromLatin1('|')));
324  const QRegularExpression startTag(
325  QStringLiteral("<%1(/?>|(\\s+[^>]*>))").arg(tagRe));
326  const QRegularExpression endTag(QStringLiteral("</%1>").arg(tagRe));
327 
328  auto value = getSafeString(input);
329  const auto safeInput = value.isSafe();
330  value.get().remove(startTag);
331  value.get().remove(endTag);
332  if (safeInput)
333  return markSafe(value);
334  return value;
335 }
336 
338  const QVariant &argument,
339  bool autoescape) const
340 {
341  Q_UNUSED(argument)
342  Q_UNUSED(autoescape)
343  static QRegularExpression tagRe(QStringLiteral("<[^>]*>"),
344  QRegularExpression::InvertedGreedinessOption);
345 
346  QString value = getSafeString(input);
347  value.remove(tagRe);
348  return value;
349 }
350 
352  const QVariant &argument,
353  bool autoescape) const
354 {
355  Q_UNUSED(autoescape)
356  QString _input = getSafeString(input);
357  auto width = argument.value<int>();
358 #if QT_VERSION < QT_VERSION_CHECK(5, 14, 0)
359  auto partList = _input.split(QLatin1Char(' '), QString::SkipEmptyParts);
360 #else
361  auto partList = _input.split(QLatin1Char(' '), Qt::SkipEmptyParts);
362 #endif
363  if (partList.isEmpty())
364  return QVariant();
365  auto output = partList.takeFirst();
366  auto pos = output.size() - output.lastIndexOf(QLatin1Char('\n')) - 1;
367  Q_FOREACH (const QString &part, partList) {
368  QStringList lines;
369  if (part.contains(QLatin1Char('\n'))) {
370  lines = part.split(QLatin1Char('\n'));
371  } else {
372  lines.append(part);
373  }
374  pos += lines.first().size() + 1;
375  if (pos > width) {
376  output.append(QLatin1Char('\n'));
377  pos += lines.last().size();
378  } else {
379  output.append(QLatin1Char(' '));
380  if (lines.size() > 1)
381  pos += lines.last().size();
382  }
383  output.append(part);
384  }
385  return output;
386 }
387 
389  const QVariant &argument,
390  bool autoescape) const
391 {
392  Q_UNUSED(autoescape)
393  double inputDouble;
394  switch (input.userType()) {
395  case QMetaType::Int:
396  case QMetaType::UInt:
397  case QMetaType::LongLong:
398  case QMetaType::ULongLong:
399  case QMetaType::Double:
400  inputDouble = input.toDouble();
401  break;
402  default:
403  inputDouble = getSafeString(input).get().toDouble();
404  }
405 
406  int precision;
407  if (argument.isValid())
408  precision = getSafeString(argument).get().toInt();
409  else
410  precision = 1;
411 
412  return QString::number(inputDouble, 'f', precision);
413 }
414 
416  const QVariant &argument,
417  bool autoescape) const
418 {
419  Q_UNUSED(argument)
420  Q_UNUSED(autoescape)
421  QVariantList list;
422  if (input.userType() == qMetaTypeId<QVariantList>()) {
423  const auto inputList = input.value<QVariantList>();
424  for (const auto &item : inputList) {
425  list << markSafe(getSafeString(item));
426  }
427  }
428  return list;
429 }
430 
432  const QVariant &argument,
433  bool autoescape) const
434 {
435  Q_UNUSED(argument)
436  auto inputString = getSafeString(input);
437  static const QRegularExpression re(QStringLiteral("\n{2,}"));
438  QStringList output;
439 
440  Q_FOREACH (const QString &bit, inputString.get().split(re)) {
441  auto _bit = SafeString(bit, inputString.isSafe());
442  if (autoescape)
443  _bit = conditionalEscape(_bit);
444  _bit.get().replace(QLatin1Char('\n'), QStringLiteral("<br />"));
445  output.append(QStringLiteral("<p>%1</p>").arg(_bit));
446  }
447  return markSafe(output.join(QStringLiteral("\n\n")));
448 }
449 
451  const QVariant &argument,
452  bool autoescape) const
453 {
454  Q_UNUSED(argument)
455  auto inputString = getSafeString(input);
456  if (autoescape && isSafeString(input)) {
457  inputString = conditionalEscape(inputString);
458  }
459  return markSafe(
460  inputString.get().replace(QLatin1Char('\n'), QStringLiteral("<br />")));
461 }
462 
463 static QString nofailStringToAscii(const QString &input)
464 {
465  QString output;
466  output.reserve(input.size());
467 
468  auto it = input.constBegin();
469  const auto end = input.constEnd();
470  static const QChar asciiEndPoint(128);
471  for (; it != end; ++it)
472  if (*it < asciiEndPoint)
473  output.append(*it);
474 
475  return output;
476 }
477 
479  const QVariant &argument,
480  bool autoescape) const
481 {
482  Q_UNUSED(argument)
483  Q_UNUSED(autoescape)
484  QString inputString = getSafeString(input);
485  inputString = inputString.normalized(QString::NormalizationForm_KD);
486  inputString = nofailStringToAscii(inputString);
487  inputString = inputString.trimmed()
488  .toLower()
489  .remove(QRegularExpression(QStringLiteral("[^\\w\\s-]")))
490  .replace(QRegularExpression(QStringLiteral("[-\\s]+")), QStringLiteral("-"));
491  return SafeString(inputString, true);
492 }
493 
495  const QVariant &argument,
496  bool autoescape) const
497 {
498  QVariant ret;
499 
500  Q_UNUSED(autoescape)
501  const auto arg = getSafeString(argument);
502  bool numberConvert = true;
503 
504  qreal size = 0.0f;
505  if (input.canConvert<qreal>()) {
506  size = input.toReal(&numberConvert);
507  if (!numberConvert) {
508  qWarning("%s", "Failed to convert input file size into floating point value.");
509  }
510  } else {
511  size = getSafeString(input).get().toDouble(&numberConvert);
512  if (!numberConvert) {
513  qWarning("%s", "Failed to convert input file size into floating point value.");
514  }
515  }
516 
517  int unitSystem = 10;
518  int precision = 2;
519  qreal multiplier = 1.0f;
520 
521  if (!arg.get().isEmpty()) {
522 #if QT_VERSION < QT_VERSION_CHECK(5, 14, 0)
523  const auto argList = arg.get().split(QLatin1Char(','), QString::SkipEmptyParts);
524 #else
525  const auto argList = arg.get().split(QLatin1Char(','), Qt::SkipEmptyParts);
526 #endif
527  const auto numArgs = argList.size();
528  if (numArgs > 0) {
529  unitSystem = argList.at(0).toInt(&numberConvert);
530  if (!numberConvert) {
531  qWarning("%s", "Failed to convert filse size format unit system into integer. Falling back to default 10.");
532  unitSystem = 10;
533  }
534  }
535 
536  if (numArgs > 1) {
537  precision = argList.at(1).toInt(&numberConvert);
538  if (!numberConvert) {
539  qWarning("%s", "Failed to convert file size format decimal precision into integer. Falling back to default 2.");
540  precision = 2;
541  }
542  }
543 
544  if (numArgs > 2) {
545  multiplier = argList.at(2).toDouble(&numberConvert);
546  if (!numberConvert) {
547  qWarning("%s", "Failed to convert file size format multiplier into double value. Falling back to default 1.0");
548  multiplier = 1.0f;
549  } else {
550  if (multiplier == 0.0f) {
551  qWarning("%s", "It makes no sense to multiply the file size by zero. Using default value 1.0.");
552  multiplier = 1.0f;
553  }
554  }
555  }
556  }
557 
558  const double sizeMult = size * multiplier;
559 
560  if (unitSystem == 10) {
561  if ((sizeMult > -1000) && (sizeMult < 1000)) {
562  precision = 0;
563  }
564  } else if (unitSystem == 2) {
565  if ((sizeMult > - 1024) && (sizeMult < 1024)) {
566  precision = 0;
567  }
568  }
569 
570  const std::pair<qreal,QString> sizePair = calcFileSize(size, unitSystem, multiplier);
571 
572  const QString retString = QString::number(sizePair.first, 'f', precision) + QLatin1Char(' ') + sizePair.second;
573 
574  ret.setValue(retString);
575 
576  return ret;
577 }
578 
579 QVariant TruncateCharsFilter::doFilter(const QVariant &input, const QVariant &argument, bool autoescape) const
580 {
581  Q_UNUSED(autoescape)
582  QString retString = getSafeString(input);
583  int count = getSafeString(argument).get().toInt();
584 
585  if(retString.length() < count) return retString;
586  retString.truncate(count);
587  retString.append(QStringLiteral("..."));
588  return retString;
589 }
590 
591 static QString escapeJson(const QString &input)
592 {
593  QString esc;
594  const int len = input.length();
595  esc.reserve(static_cast<int>(len * 1.2));
596  for (int i = 0; i < len; ++i) {
597  const QChar ch = input.at(i);
598  if (ch == QLatin1Char('>')) {
599  esc += QStringLiteral("\\\\u003E");
600  } else if (ch == QLatin1Char('<')) {
601  esc += QStringLiteral("\\\\u003C");
602  } else if (ch == QLatin1Char('&')) {
603  esc += QStringLiteral("\\\\u0026");
604  } else {
605  esc += ch;
606  }
607  }
608  esc.squeeze();
609  return esc;
610 }
611 
612 QVariant JsonScriptFilter::doFilter(const QVariant &input, const QVariant &argument, bool autoescape) const
613 {
614  Q_UNUSED(autoescape)
615  if (input.isNull() || !input.isValid()) {
616  return QVariant();
617  }
618 
619  const QString arg = escape(getSafeString(argument));
620 
621  QJsonDocument json;
622 #if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
623  if (input.userType() == qMetaTypeId<QJsonDocument>()) {
624  json = input.toJsonDocument();
625  } else if (input.userType() == qMetaTypeId<QJsonObject>()) {
626  json.setObject(input.toJsonObject());
627  } else if (input.userType() == qMetaTypeId<QJsonArray>()) {
628  json.setArray(input.toJsonArray());
629  } else if (input.userType() == qMetaTypeId<QVariantHash>()) {
630  json.setObject(QJsonObject::fromVariantHash(input.toHash()));
631  } else if (input.userType() == qMetaTypeId<QVariantMap>()) {
632  json.setObject(QJsonObject::fromVariantMap(input.toMap()));
633  } else if (input.userType() == qMetaTypeId<QVariantList>()) {
634  json.setArray(QJsonArray::fromVariantList(input.toList()));
635  } else if (input.userType() == qMetaTypeId<QStringList>()) {
636  json.setArray(QJsonArray::fromStringList(input.toStringList()));
637  } else {
638  qWarning("%s", "Can not convert input data into QJsonObject or QJSonArray.");
639  return QVariant();
640  }
641 #else
642  if (input.canConvert<QJsonDocument>()) {
643  json = input.toJsonDocument();
644  } else if (input.canConvert<QJsonObject>()) {
645  json.setObject(input.toJsonObject());
646  } else if (input.canConvert<QJsonArray>()) {
647  json.setArray(input.toJsonArray());
648  } else {
649  qWarning("%s", "Can not convert input data into QJsonObject or QJSonArray.");
650  return QVariant();
651  }
652 #endif
653 
654  QString jsonString = QString::fromUtf8(json.toJson(QJsonDocument::Compact));
655  jsonString = escapeJson(jsonString);
656 
657  const QString scriptString = u"<script id=\"" + arg + u"\" type=\"application/json\">" + jsonString + u"</script>";
658 
659  return SafeString(scriptString, true);
660 }
QVariant doFilter(const QVariant &input, const QVariant &argument={}, bool autoescape={}) const override
QVariant doFilter(const QVariant &input, const QVariant &argument={}, bool autoescape={}) const override
QVariant doFilter(const QVariant &input, const QVariant &argument={}, bool autoescape={}) const override
QVariant doFilter(const QVariant &input, const QVariant &argument={}, bool autoescape={}) const override
SafeString escape(const QString &input) const
Definition: filter.cpp:10
SafeString conditionalEscape(const SafeString &input) const
Definition: filter.cpp:22
A QString wrapper class for containing whether a string is safe or needs to be escaped.
Definition: safestring.h:92
const NestedString & get() const
Definition: safestring.h:340
QVariant doFilter(const QVariant &input, const QVariant &argument={}, bool autoescape={}) const override
QVariant doFilter(const QVariant &input, const QVariant &argument={}, bool autoescape={}) const override
QVariant doFilter(const QVariant &input, const QVariant &argument=QVariant(), bool autoescape={}) const override
QVariant doFilter(const QVariant &input, const QVariant &argument={}, bool autoescape={}) const override
QVariant doFilter(const QVariant &input, const QVariant &argument={}, bool autoescape={}) const override
QVariant doFilter(const QVariant &input, const QVariant &argument={}, bool autoescape={}) const override
QVariant doFilter(const QVariant &input, const QVariant &argument=QVariant(), bool autoescape={}) const override
QVariant doFilter(const QVariant &input, const QVariant &argument={}, bool autoescape={}) const override
QVariant doFilter(const QVariant &input, const QVariant &argument={}, bool autoescape={}) const override
QVariant doFilter(const QVariant &input, const QVariant &argument={}, bool autoescape={}) const override
QVariant doFilter(const QVariant &input, const QVariant &argument={}, bool autoescape={}) const override
QVariant doFilter(const QVariant &input, const QVariant &argument={}, bool autoescape={}) const override
QVariant doFilter(const QVariant &input, const QVariant &argument={}, bool autoescape={}) const override
QVariant doFilter(const QVariant &input, const QVariant &argument={}, bool autoescape={}) const override
QVariant doFilter(const QVariant &input, const QVariant &argument={}, bool autoescape={}) const override
QVariant doFilter(const QVariant &input, const QVariant &argument={}, bool autoescape={}) const override
QVariant doFilter(const QVariant &input, const QVariant &argument={}, bool autoescape={}) const override
QVariant doFilter(const QVariant &input, const QVariant &argument={}, bool autoescape={}) const override
bool isSafe() const override
QVariant doFilter(const QVariant &input, const QVariant &argument={}, bool autoescape={}) const override
QVariant doFilter(const QVariant &input, const QVariant &argument={}, bool autoescape={}) const override
QVariant doFilter(const QVariant &input, const QVariant &argument=QVariant(), bool autoescape={}) const override
QVariant doFilter(const QVariant &input, const QVariant &argument={}, bool autoescape={}) const override
QVariant doFilter(const QVariant &input, const QVariant &argument={}, bool autoescape={}) const override
QVariant doFilter(const QVariant &input, const QVariant &argument={}, bool autoescape={}) const override
QVariant doFilter(const QVariant &input, const QVariant &argument={}, bool autoescape={}) const override
std::pair< qreal, QString > calcFileSize(qreal size, int unitSystem=10, qreal multiplier=1.0)
Definition: util.cpp:215
bool isSafeString(const QVariant &input)
Definition: util.cpp:117
Cutelee::SafeString getSafeString(const QVariant &input)
Definition: util.cpp:108
Cutelee::SafeString markSafe(const Cutelee::SafeString &input)
Definition: util.cpp:90
Cutelee::SafeString markForEscaping(const Cutelee::SafeString &input)
Definition: util.cpp:98
Utility functions used throughout Cutelee.