private static String[][] _singleToPairArray(String[] array) { String[][] pairArray = new String[array.length][2]; for (int i = 0; i < array.length; i++) { pairArray[i][0] = HtmlUtil.escape(array[i]); pairArray[i][1] = array[i]; } return pairArray; }
private String _formatText(String text) { return HtmlUtil.escape(text); }
@Override protected String escape(T t) { return HtmlUtil.escape(String.valueOf(getOriginalValue())); }
/** * Returns the HTML-escaped name of the navigation item's layout. * * @return the HTML-escaped name of the navigation item's layout */ public String getName() { return HtmlUtil.escape(getUnescapedName()); }
protected String wrapLink(String link, String title) { title = HtmlUtil.escape(title); if (link == null) { return title; } return buildLink(link, title); }
protected String escape(Locale locale) { return HtmlUtil.escape(getOriginalValue(locale)); }
@Override public Object invoke(Object proxy, Method method, Object[] arguments) throws Throwable { String methodName = method.getName(); if (methodName.startsWith("set")) { throw new IllegalAccessException( "Setter methods cannot be called on an escaped bean"); } if (methodName.equals("getWrappedModel")) { return _bean; } else if (methodName.endsWith("isEscapedModel")) { return true; } else if (methodName.endsWith("toEscapedModel")) { return proxy; } Object result = null; try { result = method.invoke(_bean, arguments); } catch (InvocationTargetException ite) { throw ite.getTargetException(); } if (method.getAnnotation(AutoEscape.class) != null) { result = HtmlUtil.escape((String)result); } return result; }
protected String getFormattedMessage( JSONObject jsonObject, ServiceContext serviceContext, String message, String typeName) { return LanguageUtil.format( serviceContext.getLocale(), message, new String[] { HtmlUtil.escape(_getUserFullName(jsonObject)), StringUtil.toLowerCase(HtmlUtil.escape(typeName)) }, false); }
private String _escapeAndHighlight(String text) { if (!_highlight || Validator.isNull(text) || ArrayUtil.isEmpty(_queryTerms)) { if (_escape) { return HtmlUtil.escape(text); } return text; } text = HighlightUtil.highlight( text, _queryTerms, _ESCAPE_SAFE_HIGHLIGHTS[0], _ESCAPE_SAFE_HIGHLIGHTS[1]); if (_escape) { text = HtmlUtil.escape(text); } return StringUtil.replace( text, _ESCAPE_SAFE_HIGHLIGHTS, HighlightUtil.HIGHLIGHTS); }
private static void _writePaths( HttpServletResponse response, JSONArray cssPathsJSONArray, JSONArray javaScriptPathsJSONArray) throws IOException { if ((cssPathsJSONArray.length() == 0) && (javaScriptPathsJSONArray.length() == 0)) { return; } PrintWriter printWriter = response.getWriter(); for (int i = 0; i < cssPathsJSONArray.length(); i++) { String value = cssPathsJSONArray.getString(i); printWriter.print("<link href=\""); printWriter.print(HtmlUtil.escape(value)); printWriter.println("\" rel=\"stylesheet\" type=\"text/css\" />"); } for (int i = 0; i < javaScriptPathsJSONArray.length(); i++) { String value = javaScriptPathsJSONArray.getString(i); printWriter.print("<script src=\""); printWriter.print(HtmlUtil.escape(value)); printWriter.println("\" type=\"text/javascript\"></script>"); } }
public RepositoryConfigurationBuilder addParameter(String name) { String labelKey = HtmlUtil.escape( StringUtil.replace( StringUtil.toLowerCase(name), CharPool.UNDERLINE, CharPool.DASH)); return addParameter(name, labelKey); }
public String getUserNameLink(long userId, ThemeDisplay themeDisplay) { try { if (userId <= 0) { return StringPool.BLANK; } User user = UserLocalServiceUtil.getUserById(userId); String userName = user.getFullName(); String userDisplayURL = user.getDisplayURL(themeDisplay); return StringBundler.concat( "<a href=\"", userDisplayURL, "\">", HtmlUtil.escape(userName), "</a>"); } catch (Exception e) { return StringPool.BLANK; } }
public String getUserName(long userId, ThemeDisplay themeDisplay) { try { if (userId <= 0) { return StringPool.BLANK; } User user = UserLocalServiceUtil.getUserById(userId); if (user.getUserId() == themeDisplay.getUserId()) { return HtmlUtil.escape(user.getFirstName()); } String userName = user.getFullName(); Group group = user.getGroup(); if (group.getGroupId() == themeDisplay.getScopeGroupId()) { return HtmlUtil.escape(userName); } String userDisplayURL = user.getDisplayURL(themeDisplay); return StringBundler.concat( "<a href=\"", userDisplayURL, "\">", HtmlUtil.escape(userName), "</a>"); } catch (Exception e) { return StringPool.BLANK; } }
/** * @deprecated As of Wilberforce (7.0.x), replaced by {@link * #getUserName(long, ServiceContext)} */ @Deprecated protected String getUserName(long userId, ThemeDisplay themeDisplay) { try { if (userId <= 0) { return StringPool.BLANK; } User user = UserLocalServiceUtil.getUserById(userId); if (user.getUserId() == themeDisplay.getUserId()) { return HtmlUtil.escape(user.getFirstName()); } String userName = user.getFullName(); Group group = user.getGroup(); if (group.getGroupId() == themeDisplay.getScopeGroupId()) { return HtmlUtil.escape(userName); } String userDisplayURL = user.getDisplayURL(themeDisplay); userName = StringBundler.concat( "<a class=\"user\" href=\"", userDisplayURL, "\">", HtmlUtil.escape(userName), "</a>"); return userName; } catch (Exception e) { return StringPool.BLANK; } }
protected String getUserName(long userId, ServiceContext serviceContext) { try { if (userId <= 0) { return StringPool.BLANK; } User user = UserLocalServiceUtil.getUserById(userId); if (user.getUserId() == serviceContext.getUserId()) { return HtmlUtil.escape(user.getFirstName()); } String userName = user.getFullName(); Group group = user.getGroup(); if (group.getGroupId() == serviceContext.getScopeGroupId()) { return HtmlUtil.escape(userName); } String userDisplayURL = user.getDisplayURL( serviceContext.getThemeDisplay()); userName = StringBundler.concat( "<a class=\"user\" href=\"", userDisplayURL, "\">", HtmlUtil.escape(userName), "</a>"); return userName; } catch (Exception e) { return StringPool.BLANK; } }
private MailTemplateContext _getBodyMailTemplateContext( Locale locale, InternetAddress from, InternetAddress to) { MailTemplateContextBuilder mailTemplateContextBuilder = MailTemplateFactoryUtil.createMailTemplateContextBuilder(); mailTemplateContextBuilder.put("[$FROM_ADDRESS$]", from.getAddress()); mailTemplateContextBuilder.put( "[$FROM_NAME$]", HtmlUtil.escape( GetterUtil.getString(from.getPersonal(), from.getAddress()))); mailTemplateContextBuilder.put( "[$TO_ADDRESS$]", HtmlUtil.escape(to.getAddress())); mailTemplateContextBuilder.put( "[$TO_NAME$]", HtmlUtil.escape( GetterUtil.getString(to.getPersonal(), to.getAddress()))); MailTemplateContext mailTemplateContext = mailTemplateContextBuilder.build(); return mailTemplateContext.aggregateWith( _getBasicMailTemplateContext(locale)); }
@Override protected String getBody( UserNotificationEvent userNotificationEvent, ServiceContext serviceContext) throws Exception { JSONObject jsonObject = JSONFactoryUtil.createJSONObject( userNotificationEvent.getPayload()); AssetRenderer<?> assetRenderer = getAssetRenderer(jsonObject); if (assetRenderer == null) { UserNotificationEventLocalServiceUtil.deleteUserNotificationEvent( userNotificationEvent.getUserNotificationEventId()); return null; } return StringUtil.replace( getBodyTemplate(), new String[] {"[$BODY$]", "[$TITLE$]"}, new String[] { HtmlUtil.escape( StringUtil.shorten(getBodyContent(jsonObject), 70)), getTitle(jsonObject, assetRenderer, serviceContext) }); }
sb.append(HtmlUtil.escape(mvcRenderCommandName)); sb.append("\" for portlet "); sb.append(renderRequest.getAttribute(WebKeys.PORTLET_ID));