@Override protected JsonObject createEmptyWidget(String rteName) { JsonObject object = new JsonObject(); object.addProperty("xtype", "richtext"); object.addProperty("name", "./" + xssApi.encodeForJSString(rteName)); object.addProperty("hideLabel", true); object.addProperty("jcr:primaryType", "cq:Widget"); return object; }
@Override protected JsonObject createEmptyWidget(String propertyName) { JsonObject object = new JsonObject(); object.addProperty("xtype", "tags"); object.addProperty("name", "./" + xssApi.encodeForJSString(propertyName)); object.addProperty("fieldLabel", "Tags/Keywords"); object.addProperty("jcr:primaryType", "cq:Widget"); return object; }
/** * Encode a string for an JavaScript string. * * @param xssAPI the XSSAPI * @param source the source string * @return the encoded string */ @Function public static CharSequence encodeForJSString(XSSAPI xssAPI, String source) { return xssAPI.encodeForJSString(source); }
/** * Use to encapsulate new-style (XSSAPI-based) encoding for JavaScript strings. * * @param source the string to be encoded * @return the encoded string */ public static String encodeForJSString(String source) { XSSAPI xssAPI = new XSSAPIImpl(); return xssAPI.encodeForJSString(source); }
@Activate @SuppressWarnings("squid:S1149") protected final void activate(ComponentContext ctx) { Dictionary<?, ?> config = ctx.getProperties(); color = PropertiesUtil.toString(config.get(PROP_COLOR), ""); cssOverride = PropertiesUtil.toString(config.get(PROP_CSS_OVERRIDE), ""); innerHTML = PropertiesUtil.toString(config.get(PROP_INNER_HTML), ""); innerHTML = new StrSubstitutor(StrLookup.systemPropertiesLookup()).replace(innerHTML); // Only write CSS variable if cssOverride or color is provided if (StringUtils.isNotBlank(cssOverride)) { css = cssOverride; } else if (StringUtils.isNotBlank(color)) { css = createCss(color); } titlePrefix = xss.encodeForJSString( PropertiesUtil.toString(config.get(PROP_TITLE_PREFIX), "").toString()); if (StringUtils.isNotBlank(css) || StringUtils.isNotBlank(titlePrefix)) { Dictionary<String, String> filterProps = new Hashtable<String, String>(); filterProps.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_FILTER_PATTERN, "/"); filterProps.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_SELECT, "(" + HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_NAME + "=*)"); filterRegistration = ctx.getBundleContext().registerService(Filter.class.getName(), this, filterProps); } excludedWCMModes = PropertiesUtil.toStringArray(config.get(PROP_EXCLUDED_WCMMODES),DEFAULT_EXCLUDED_WCMMODES); }
@Override protected void doGet(SlingHttpServletRequest request, SlingHttpServletResponse response) throws ServletException, IOException { XSSAPI xssApi = request.adaptTo(XSSAPI.class); JsonObject result = new JsonObject(); JsonArray list = new JsonArray(); result.add("list", list); ServiceReference[] services = tracker.getServiceReferences(); if (services != null) { for (ServiceReference service : services) { String displayName = PropertiesUtil.toString(service.getProperty("displayName"), null); String[] schemes = PropertiesUtil.toStringArray(service.getProperty(Importer.SCHEME_PROPERTY)); if (displayName != null && schemes != null) { for (String scheme : schemes) { JsonObject obj = new JsonObject(); obj.addProperty("qtip", ""); obj.addProperty("text", displayName); obj.addProperty("text_xss", xssApi.encodeForJSString(displayName)); obj.addProperty("value", scheme); list.add(obj); } } } } response.setCharacterEncoding("UTF-8"); response.setContentType("application/json"); Gson gson = new Gson(); gson.toJson(result, response.getWriter()); }
@Override protected JSONObject createEmptyWidget(String propertyName) throws JSONException { JSONObject object = new JSONObject(); object.put("xtype", "tags"); object.put("name", "./" + xssApi.encodeForJSString(propertyName)); object.put("fieldLabel", "Tags/Keywords"); object.put("jcr:primaryType", "cq:Widget"); return object; }
@Override protected JSONObject createEmptyWidget(String rteName) throws JSONException { JSONObject object = new JSONObject(); object.put("xtype", "richtext"); object.put("name", "./" + xssApi.encodeForJSString(rteName)); object.put("hideLabel", true); object.put("jcr:primaryType", "cq:Widget"); return object; }
return xssApi.getValidStyleToken(text, ""); case SCRIPT_STRING: return xssApi.encodeForJSString(text); case STYLE_STRING: return xssApi.encodeForCSSString(text);
obj.put("qtip", ""); obj.put("text", displayName); obj.put("text_xss", xssAPI.encodeForJSString(displayName)); obj.put("value", scheme); list.put(obj);