code: public static String sanitizeCategory(String category) {
          String res = null;
          if (StringUtils.isNotBlank(category)) {
              res = category.trim().replaceAll("[^" + CATEGORYNAME_CHARS + "]", "");
              if (!res.equals(category)) LOG.error("Invalid characters in category {}", category);
          }
          return res;
      }
docs: Removes invalid chars (according to {@link #CATEGORYNAME_CHARS}) from a category; returns null if there is
  nothing left / was empty, anyway.