Refine search
/** * @param formattedText The formatted text to convert to plain text and then to trim * @param maxNumOfChars The maximum number of characters for the trimmed text. * @return Ellipse A String to represent the ending pattern of the trimmed text */ public String doPlainTextAndLimit(String formattedText, int maxNumOfChars, String ellipse) { formattedText = StringUtils.trimToNull(formattedText); if(formattedText == null || formattedText.equalsIgnoreCase("<br/>") || formattedText.equalsIgnoreCase("<br>")|| formattedText.equals(" ") || FormattedText.escapeHtml(formattedText,false).equals("<br type="_moz" />")){ return ""; } StringBuilder sb = new StringBuilder(); String text = FormattedText.convertFormattedTextToPlaintext(formattedText); if(maxNumOfChars>text.length()){ maxNumOfChars=text.length(); } String trimmedText=text.substring(0, maxNumOfChars); sb.setLength(0); sb.append(trimmedText).append(ellipse); return Validator.escapeHtml(sb.toString()); } }
private String makeIdCleanAndLengthCompliant (String path) { String [] parts = path.split("/"); StringBuilder rv = new StringBuilder(); for (int i = 0; i < parts.length; i++) { if (parts[i].length() > 0) { rv.append("/" + Validator.escapeResourceName(parts[i])); } } // SAK-18833, the content resource must be less than 255 chars if (rv.length() > (255 - 5)) { // leave at least 14 characters at end for uniqueness // leave an additional 5 characters for an extension like .html rv.setLength(255 - 14 - 5); // add a timestamp to differentiate it (+14 chars) Format f = new SimpleDateFormat("yyyyMMddHHmmss"); rv.append(f.format(new Date())); if (log.isDebugEnabled()) { log.debug("makeIdCleanAndLengthCompliant truncated from {} to {}", path, rv.toString()); } } return rv.toString(); }
/** * Return a string based on id that is fully escaped using URL rules, using a UTF-8 underlying encoding. * * Note: java.net.URLEncode.encode() provides a more standard option * FormattedText.decodeNumericCharacterReferences() undoes this op * * @param id * The string to escape. * @return id fully escaped using URL rules. * @deprecated just a passthrough for {@link Validator#escapeUrl(String)} so use that instead */ public static String escapeUrl(String id) { return Validator.escapeUrl( id ); } // escapeUrl
if ( pieces.length > 6 && "tool".equals(pieces[6]) ) { String queryString = req.getQueryString(); if ( queryString != null ) pagerefUrl = pagerefUrl + '?' + queryString; log.warn("Redirecting tool inline url: "+pagerefUrl); log.debug("allowBuffer="+allowBuffer+" url="+req.getRequestURL()); TCP = req.getContextPath() + req.getServletPath() + Web.makePath(parts, 1, 5); toolPathInfo = Web.makePath(parts, 5, parts.length); }else{ rcontext.put("siteTitle", portal.getSiteHelper().getUserSpecificSiteTitle(site, false, true, providers)); rcontext.put("siteTitleTruncated", Validator.escapeHtml(portal.getSiteHelper().getUserSpecificSiteTitle(site, true, false, providers))); rcontext.put("isUserSite", false);
ParameterParser params = (ParameterParser) req.getAttribute(ATTR_PARAMS); String acceptedRef = req.getParameter(COPYRIGHT_ACCEPT_REF); String returnPath = req.getParameter(COPYRIGHT_ACCEPT_URL); setVmReference("validator", new Validator(), req); setVmReference("props", props, req); setVmReference("tlang", rb, req); String acceptPath = Web.returnUrl(req, COPYRIGHT_ACCEPT + "?" + COPYRIGHT_ACCEPT_REF + "=" + Validator.escapeUrl(aRef.getReference()) + "&" + COPYRIGHT_ACCEPT_URL + "=" + Validator.escapeUrl(returnPath)); String returnPath = Validator.escapeUrl( req.getParameter(COPYRIGHT_ACCEPT_URL) ); String redirPath = COPYRIGHT_REQUIRE + "?" + COPYRIGHT_ACCEPT_REF + "=" + Validator.escapeUrl(e.getReference()) + "&" + COPYRIGHT_ACCEPT_URL + "=" + Validator.escapeUrl(req.getPathInfo()); res.sendRedirect(Web.returnUrl(req, redirPath));
if (req.getHeader("Range") != null) { sendError(res, HttpServletResponse.SC_FORBIDDEN); return; session.setAttribute(Tool.HELPER_DONE_URL, Web.returnUrl(req, Validator.escapeUrl(path))); String context = req.getContextPath() + req.getServletPath() + "/login"; tool.help(req, res, context, "/login");
+ "<title>" + rb.getString("list.title") + ": " + Validator.escapeHtml(title) + "</title>\n" + "<link href=\"/library/skin/tool_base.css\" type=\"text/css\" rel=\"stylesheet\" media=\"all\" />\n" boolean isPrintView = req.getParameter("printView")!=null; out.println("\t<div style=\"width: 100%; height: 90px; line-height: 90px; background-color:" + ServerConfigurationService.getString("official.institution.background.colour") +"; \">" + "<div class=\"banner\"><h1 style=\" margin-left:15px; color:" + ServerConfigurationService.getString("official.institution.text.colour") + ";\">" + Validator.escapeHtml(title) + "</h1></div> " + "<div class=\"bannerLinks\">" + (!isPrintView ? "<a class=\"export\" href=" + exportUrlAll + ">Export</a>" + "<a class=\"print\" target=\"_blank\" href=" + req.getRequestURL() + "?printView" + ">Print</a>" : "") + "<div class=\"lastUpdated\">Last updated: " + displayDate + "</div>" + "</div>" + "</div>"); out.println("<div style=\"clear:both;\"></div>");
String fileName = Validator.getFileName(ref.getId()); String disposition = null; if (Validator.letBrowserInline(contentType)) long headerValue = req.getDateHeader("If-Modified-Since"); if (headerValue != -1 && (lastModTime < headerValue + 1000)) { if (directLinkUri != null || req.getHeader("Range") == null || (ranges == null) || (ranges.isEmpty())) { res.addHeader("Accept-Ranges", "none"); res.setContentType(contentType);
id = Validator.escapeQuestionMark(id); relId = Validator.escapeQuestionMark(relId);
String siteId = Validator.escapeResourceName(site); String toolId = Validator.escapeResourceName(tool); Validator.checkResourceId(name);
+ rb.getString("announcement") + ": " + Validator.escapeHtml(hdr.getSubject()) + "</title>" + "</head>\n<body>"); + Validator.escapeHtml(hdr.getFrom().getDisplayName()) + "</td></tr>"); out.println("<tr><td><b>" + rb.getString("date_colon") + "</b></td><td>" + Validator.escapeHtml(hdr.getDate().toStringLocalFull()) + "</td></tr>"); out.println("<tr><td><b>" + rb.getString("subject_colon") + "</b></td><td>" + Validator.escapeHtml(hdr.getSubject()) + "</td></tr></table>"); out.println("<p>" + Validator.escapeHtmlFormattedText(msg.getBody()) + "</p>"); out.println("<a href=\"" + Validator.escapeHtml(attachment.getUrl()) + "\">" + Validator.escapeHtml(attachment.getUrl()) + "</a><br />");
if (!Validator.checkResourceId(id)) { throw new IdInvalidException("Id " + id + " is not a valid id format"); id = Validator.escapeResourceName(id); if (!Validator.checkSiteType(type)) { throw new IdInvalidException("Type " + type + " is not a valid type format");
/** * @see org.sakaiproject.content.api.ContentHostingService#addAttachmentResource(java.lang.String, java.lang.String, InputStream, org.sakaiproject.entity.api.ResourceProperties) */ public ContentResource addAttachmentResource(String name, String type, InputStream content, ResourceProperties properties) throws IdInvalidException, InconsistentException, IdUsedException, PermissionException, OverQuotaException, ServerOverloadException { // make sure the name is valid Validator.checkResourceId(name); // resource must also NOT end with a separator characters (we fix it) if (name.endsWith(Entity.SEPARATOR)) { name = name.substring(0, name.length() - 1); } // form a name based on the attachments collection, a unique folder id, and the given name String collection = ATTACHMENTS_COLLECTION + idManager.createUuid() + Entity.SEPARATOR; String id = collection + name; if (id.length() > MAXIMUM_RESOURCE_ID_LENGTH) { throw new RuntimeException(ID_LENGTH_EXCEPTION); } // add this collection addAndCommitAttachmentCollection(collection, name, null); // and add the resource return addResource(id, type, content, properties, new ArrayList(), NotificationService.NOTI_NONE); } // addAttachmentResource
<script type="text/javascript"> var frmvalidator = new Validator("ExporterEditContactPersonForm"); frmvalidator.EnableOnPageErrorDisplay(); frmvalidator.EnableMsgsTogether(); frmvalidator.addValidation("landMark", "regexp=^\S", "Landmark should not start with space"); //\s matched white space and \S matched non white space so you need to check if it not white space frmvalidator.addValidation("landMark", "regexp=^[a-zA-Z0-9]", "Landmark should not start with special character");
/** * Determine whether a file resource should be opened in the current window or a new window. * * @param contentType * The content type to check * @return A string identifying the window in which to open the resource: "_self" to open the resource in the current window, "_blank" for a new window, or an empty string if the resource is not a file. */ public static String getResourceTarget(String contentType) { // we will open a new window unless... String rv = "_blank"; // get the resource's type if (contentType != null) { // if the browser will not inline, but mark as attachments, let's not open a new window if (!letBrowserInline(contentType)) { rv = "_self"; } } return rv; } // getResourceTarget
if ( text != null) buffer.append(rb.getString("gen.submittedtext") + newline + newline + Validator.escapeHtmlFormattedText(text) + newline + newline);
if ( pieces.length > 6 && "tool".equals(pieces[6]) ) { String queryString = req.getQueryString(); if ( queryString != null ) pagerefUrl = pagerefUrl + '?' + queryString; log.warn("Redirecting tool inline url: "+pagerefUrl); log.debug("allowBuffer="+allowBuffer+" url="+req.getRequestURL()); TCP = req.getContextPath() + req.getServletPath() + Web.makePath(parts, 1, 5); toolPathInfo = Web.makePath(parts, 5, parts.length); }else{ rcontext.put("siteTitle", portal.getSiteHelper().getUserSpecificSiteTitle(site, false, true, providers)); rcontext.put("siteTitleTruncated", Validator.escapeHtml(portal.getSiteHelper().getUserSpecificSiteTitle(site, true, false, providers))); rcontext.put("isUserSite", false);
element5.setAttribute("relative-url", Validator.escapeQuestionMark(newUrl)); element5.setAttribute("relative-url", Validator.escapeQuestionMark(newUrl)); .escapeQuestionMark(newUrl)); element5.setAttribute("relative-url", Validator.escapeQuestionMark(newUrl));
if (!Validator.checkResourceId(id)) { throw new IdInvalidException("Id " + id + " is not valid"); id = Validator.escapeResourceName(id);
Validator.checkResourceId(name);