List of usage examples for org.apache.commons.lang StringEscapeUtils escapeHtml
public static String escapeHtml(String input)
From source file:de.arago.rike.task.action.SaveTask.java
@Override public void execute(IDataWrapper data) throws Exception { Task task = new Task(); String user = SecurityHelper.getUserEmail(data.getUser()); Artifact artifact = new DataHelperRike<Artifact>(Artifact.class).find(data.getRequestAttribute("artifact")); task.setTitle(data.getRequestAttribute("title")); task.setUrl(data.getRequestAttribute("url")); task.setArtifact(artifact);/*from w ww. ja v a 2 s .c o m*/ task.setCreated(new Date()); task.setCreator(user); task.setDescription(data.getRequestAttribute("description")); task.setStatus(Status.UNKNOWN); task.setMilestone( new DataHelperRike<Milestone>(Milestone.class).find(data.getRequestAttribute("milestone"))); try { task.setSizeEstimated(Integer.valueOf(data.getRequestAttribute("size_estimated"), 10)); } catch (Exception ignored) { } int priority = Integer.parseInt(GlobalConfig.get(PRIORITY_NORMAL)); task.setPriority(priority); try { SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd"); task.setDueDate(format.parse(data.getRequestAttribute("due_date"))); } catch (Exception ignored) { } TaskHelper.save(task); StatisticHelper.update(); HashMap<String, Object> notificationParam = new HashMap<String, Object>(); notificationParam.put("id", task.getId().toString()); data.setEvent("TaskUpdateNotification", notificationParam); data.setEvent("TaskSelectNotification", notificationParam); ActivityLogHelper.log( " created Task #" + task.getId() + " <a href=\"/web/guest/rike/-/show/task/" + task.getId() + "\">" + StringEscapeUtils.escapeHtml(task.getTitle()) + "</a>", task.getStatus(), user, data, task.toMap()); }
From source file:hudson.plugins.emailext.plugins.content.BuildLogRegexContent.java
private void appendContextLine(StringBuffer buffer, String line, boolean escapeHtml) { if (escapeHtml) { line = StringEscapeUtils.escapeHtml(line); }/*from w ww . j a v a 2s .c o m*/ buffer.append(line); buffer.append('\n'); }
From source file:com.edgenius.wiki.render.handler.LinkHandler.java
public List<RenderPiece> handle(RenderContext renderContext, Map<String, String> values) throws RenderHandlerException { String view = values.get(NameConstants.VIEW); String name = values.get(NameConstants.NAME); List<RenderPiece> pieces = new ArrayList<RenderPiece>(); int type = NumberUtils.toInt(values.get(NameConstants.TYPE)); if (name != null) { if (type == LinkModel.LINK_TO_ATTACHMENT) { //download link for attachment String spaceUname = renderContext.getSpaceUname(); CrFileNode node = null;/*from www. j av a 2s . c o m*/ try { ITicket ticket = repositoryService.login(spaceUname, spaceUname, spaceUname); node = repositoryService.getLatestCRFileNode(ticket, RepositoryService.TYPE_ATTACHMENT, pageUuid, name); if (node != null) { Map<String, String> attributes = new HashMap<String, String>(); attributes.put(NameConstants.HREF, renderContext.buildDownloadURL(name, node.getNodeUuid(), true)); attributes.put(NameConstants.TITLE, "Download file " + StringEscapeUtils.escapeHtml(name)); pieces.add(new TextModel(HTMLUtil.buildTagString("a", view, attributes))); } } catch (RepositoryException e) { Log.error("Unable to get file node", e); } if (node == null) { //error - doesn't exist throw new RenderHandlerException("The attachment doesn't exist."); } } else if (type == LinkModel.LINK_TO_READONLY) { //the case is, page no "link to create" permission, and linked page not existed. then simple put view //this view maybe pure text, or some markup, such as image //build tag Map<String, String> attributes = new HashMap<String, String>(); //We don't need put link meta info into Wajax as it won't convert back to Markup at this scenario. // Map<String,String> wajaxMap = new HashMap<String,String>(); // wajaxMap.put(NameConstants.TYPE, String.valueOf(type)); // //here, name is already removed leading "^" // wajaxMap.put(NameConstants.LINK, name); // String wajax = RichTagUtil.buildWajaxAttributeString(LinkModel.class.getName(),wajaxMap); // attributes.put(NameConstants.WAJAX, wajax); attributes.put(NameConstants.HREF, "javascript:;"); attributes.put("onClick", "alert(\"" + messageService.getMessage("readonly.link") + "\")"); pieces.add(new TextModel(HTMLUtil.buildTagString("a", view, attributes))); } else { //page link LinkModel link = new LinkModel(); link.setLink(name); link.setType(type); link.setSpaceUname(values.get(NameConstants.SPACE)); link.setView(view); if (!StringUtils.isBlank(values.get(NameConstants.ANCHOR))) { link.setAnchor(values.get(NameConstants.ANCHOR)); } link.setLinkTagStr(renderContext.buildURL(link)); pieces.add(link); } } else { //[http://foo.com] will go here..., no name, but view is http... //please note, at this moment, view is already surrounding by link, e.g., <a href=xxx>view</a>, so here just replace view. pieces.add(new TextModel(view)); } return pieces; }
From source file:AddPost.java
/** * rimuore i tag < e > di html per evitare che possano essere * lanciati script direttamente da commento sul server * @param post/* ww w . j av a 2 s. c om*/ * @return */ private String cleanString(String post) { post = StringEscapeUtils.escapeHtml(post); return post; }
From source file:com.sonymobile.backlogtool.Story.java
/** * @return the title */ public String getTitle() { return StringEscapeUtils.escapeHtml(title); }
From source file:gov.nih.nci.ncicb.cadsr.contexttree.CDEBrowserTreeData.java
private LazyActionTreeNode buildTree() { log.info("Building CDE Browser tree start ...."); ContextDAO dao = daoFactory.getContextDAO(); LazyActionTreeNode contextFolder = new LazyActionTreeNode("Context Folder", "caDSR Contexts", "javascript:performAction('P_PARAM_TYPE=CONTEXT" + "&NOT_FIRST_DISPLAY=1&performQuery=yes')", false);/*from w w w. j a va2s . co m*/ contextFolder.setParent(null); contextFolder.setTreeModel(new LazyActionTreeModel(contextFolder)); boolean excludeTraining = true; boolean excludeTest = true; boolean noBuildException = true; try { FacesContext facesContext = FacesContext.getCurrentInstance(); HttpSession session = (HttpSession) facesContext.getExternalContext().getSession(false); //first build a text folder node context. Collection<Context> contexts = (Collection) session.getAttribute(FormConstants.ALL_CONTEXTS); if (contexts == null || contexts.size() < 1) { contexts = dao.getAllContexts(); DataElementSearchBean desb = (DataElementSearchBean) (SessionHelper.getInfoBean(session, "desb")); if (desb == null) { desb = new DataElementSearchBean(); desb.initDefaultContextPreferences(); } desb.getContextsList(contexts); } for (Iterator iter = contexts.iterator(); iter.hasNext();) { Context context = (Context) iter.next(); LazyActionTreeNode contextNode = new ContextNode("Context Folder", context.getName() + " (" + context.getDescription() + ")", "javascript:performAction('P_PARAM_TYPE=CONTEXT&P_IDSEQ=" + context.getConteIdseq() + "&P_CONTE_IDSEQ=" + context.getConteIdseq() + StringEscapeUtils.escapeHtml( "&PageId=DataElementsGroup&NOT_FIRST_DISPLAY=1&performQuery=yes") + "')", context.getConteIdseq(), false); contextFolder.addLeaf(contextNode); } } catch (Exception e) { noBuildException = false; log.error("Exception caught when building the tree", e); throw new RuntimeException(e); } contextFolder.setLoaded(noBuildException); contextFolder.setExpanded(noBuildException); log.info("Finished Building CDE Browser tree"); return contextFolder; }
From source file:com.buaa.cfs.conf.ReconfigurationServlet.java
/** * Print configuration options that can be changed. *//*w ww .ja va 2 s . com*/ private void printConf(PrintWriter out, Reconfigurable reconf) { Configuration oldConf = reconf.getConf(); Configuration newConf = new Configuration(); Collection<ReconfigurationUtil.PropertyChange> changes = ReconfigurationUtil.getChangedProperties(newConf, oldConf); boolean changeOK = true; out.println("<form action=\"\" method=\"post\">"); out.println("<table border=\"1\">"); out.println("<tr><th>Property</th><th>Old value</th>"); out.println("<th>New value </th><th></th></tr>"); for (ReconfigurationUtil.PropertyChange c : changes) { out.print("<tr><td>"); if (!reconf.isPropertyReconfigurable(c.prop)) { out.print("<font color=\"red\">" + StringEscapeUtils.escapeHtml(c.prop) + "</font>"); changeOK = false; } else { out.print(StringEscapeUtils.escapeHtml(c.prop)); out.print("<input type=\"hidden\" name=\"" + StringEscapeUtils.escapeHtml(c.prop) + "\" value=\"" + StringEscapeUtils.escapeHtml(c.newVal) + "\"/>"); } out.print("</td><td>" + (c.oldVal == null ? "<it>default</it>" : StringEscapeUtils.escapeHtml(c.oldVal)) + "</td><td>" + (c.newVal == null ? "<it>default</it>" : StringEscapeUtils.escapeHtml(c.newVal)) + "</td>"); out.print("</tr>\n"); } out.println("</table>"); if (!changeOK) { out.println("<p><font color=\"red\">WARNING: properties marked red" + " will not be changed until the next restart.</font></p>"); } out.println("<input type=\"submit\" value=\"Apply\" />"); out.println("</form>"); }
From source file:net.landora.video.infopanel.VideoInfoPanel.java
@Override public void loadContext(MultiValueMap context) { Collection col = context.getCollection(VideoMetadata.class); VideoMetadata md = (VideoMetadata) UIUtils.select(col); byte[] data = md.getPosterImage(); if (data == null) { lblPicture.setIcon(null);/*from w w w .ja va2 s . c o m*/ } else { try { Image img = ImageIO.read(new ByteArrayInputStream(data)); lblPicture.setIcon(new ImageIcon(img)); } catch (IOException ex) { lblPicture.setIcon(null); LoggerFactory.getLogger(getClass()).warn("Error loading image.", ex); } } Map<String, String> values = md.getAllInformation(false); StringBuilder buffer = new StringBuilder(); buffer.append("<html>"); Font font = lblPicture.getFont(); buffer.append("<head>"); buffer.append("<style type=\"text/css\">"); buffer.append(" { margin-top: 0px; margin-bottom: 0px; margin-right: 0px; margin-left: 0px; }"); buffer.append("table { border-collapse:collapse; }"); buffer.append(" td { "); buffer.append(" font-family: \""); buffer.append(font.getFamily()); buffer.append("\"; font-size: "); buffer.append(font.getSize() - 2); buffer.append("px; "); buffer.append(" }\n"); buffer.append(" td.label { "); buffer.append("text-align: right; "); buffer.append("font-weight:bold; "); buffer.append("white-space:nowrap; "); buffer.append(" font-family: \""); buffer.append(font.getFamily()); buffer.append("\"; font-size: "); buffer.append(font.getSize() - 2); buffer.append("px; "); buffer.append("} "); buffer.append("</style>"); buffer.append("</head>"); buffer.append("<body>"); buffer.append("<table>"); boolean first = true; for (Map.Entry<String, String> entry : values.entrySet()) { buffer.append("<tr><td class=\"label\">"); buffer.append(StringEscapeUtils.escapeHtml(entry.getKey())); buffer.append("</td><td>"); buffer.append(StringEscapeUtils.escapeHtml(entry.getValue())); buffer.append("</td></tr>"); } buffer.append("</table>"); buffer.append("</body>"); buffer.append("</html>"); txtInfo.setContentType("text/html"); txtInfo.setText(buffer.toString()); }
From source file:com.redhat.rhn.frontend.servlets.EnvironmentFilter.java
private void addParameterizedMessages(HttpServletRequest req) { String messageKey = req.getParameter("message"); if (messageKey != null) { ActionMessages msg = new ActionMessages(); String param1 = req.getParameter("messagep1"); String param2 = req.getParameter("messagep2"); String param3 = req.getParameter("messagep3"); Object[] args = new Object[3]; args[0] = StringEscapeUtils.escapeHtml(param1); args[1] = StringEscapeUtils.escapeHtml(param2); args[2] = StringEscapeUtils.escapeHtml(param3); msg.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage(messageKey, args)); StrutsDelegate.getInstance().saveMessages(req, msg); }// w w w. j a v a 2 s .c o m }
From source file:com.epam.cme.storefront.util.PageTitleResolver.java
public <STATE> String resolveSearchPageTitle(final String searchText, final List<BreadcrumbData<STATE>> appliedFacets) { final CMSSiteModel currentSite = getCmsSiteService().getCurrentSite(); final StringBuilder builder = new StringBuilder(); if (!StringUtils.isEmpty(searchText)) { builder.append(searchText).append(SEPARATOR); }//from w w w .java 2s.c o m for (final BreadcrumbData pathElement : appliedFacets) { builder.append(pathElement.getFacetValueName()).append(SEPARATOR); } builder.append(currentSite.getName()); return StringEscapeUtils.escapeHtml(builder.toString()); }