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(); }
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(); }
protected String getResourceEmbed(Node questionNode) { String uri = XPathHelper.getNodeValue("./presentation/flow/flow[@class='QUESTION_BLOCK']/flow[@class='FILE_BLOCK']/material/matapplication[1]/@uri", questionNode); // get rid of those pesky back slashes uri = uri.replaceAll("\\\\", "/"); // run the filename only (not the directories) through the resource escaper String[] subPath = uri.split(Pattern.quote("/")); log.debug("s: {}", Arrays.toString(subPath)); String fileName = subPath[subPath.length-1]; String cleanedFileName = Validator.escapeResourceName(fileName); uri = uri.replaceAll(fileName, cleanedFileName); log.debug("replacing: {}::{}::{}", fileName, cleanedFileName, uri); Matcher matcher = imgPattern.matcher(uri); if (matcher.matches()) { return "\n<br/><img alt=\"\" src=\"" + uri + "\" />"; } else if (!"".equals(uri)) { String label = XPathHelper.getNodeValue("./presentation/flow/flow[@class='QUESTION_BLOCK']/flow[@class='FILE_BLOCK']/material/matapplication[1]/@label", questionNode); if ("".equals(label)) { label = "Document Link"; } return "\n<br/><br/><IMG SRC=\"/library/image/silk/report.png\" alt=\"\" /> <a href=\"" + uri + "\">" + label + "</a>"; } else { return ""; } }
/** * Calculate a candidate for a resource id for a resource being copied/moved into a new folder. * * @param id * @param folder_id * @exception PermissionException * if the user does not have permissions to read the properties for the existing resource. * @exception IdUnusedException * if the resource id is not found. */ protected String newName(String id, String folder_id) throws PermissionException, IdUnusedException { String filename = isolateName(id); if (filename == null || filename.length() == 0) { ResourceProperties props = getProperties(id); filename = props.getProperty(ResourceProperties.PROP_DISPLAY_NAME); } filename = Validator.escapeResourceName(filename); if(! folder_id.endsWith(Entity.SEPARATOR)) { folder_id += Entity.SEPARATOR; } return folder_id + filename; }
String siteId = Validator.escapeResourceName(site); String toolId = Validator.escapeResourceName(tool);
basename = Validator.escapeResourceName(basename.trim()); extension = Validator.escapeResourceName(extension);
Validator.escapeResourceName(oAttachment.getProperties().getProperty(ResourceProperties.PROP_DISPLAY_NAME)), toContext, ToolManager.getTool("sakai.assignment.grades").getTitle(), Validator.escapeResourceName(oAttachment.getProperties().getProperty(ResourceProperties.PROP_DISPLAY_NAME)), toContext, 1,
fileName = Validator.escapeResourceName(fileName); String folderId = isolateContainingId(new_id);
name = Validator.escapeResourceName(name.trim()); checkCollection(collectionId);
name = Validator.escapeResourceName(name.trim()); checkCollection(collectionId);
if(newProps.getProperty(ResourceProperties.PROP_DISPLAY_NAME) == null) name = Validator.escapeResourceName(name);
Validator.escapeResourceName(oAttachment.getProperties().getProperty(ResourceProperties.PROP_DISPLAY_NAME)), Validator.escapeResourceName(oAttachment.getProperties().getProperty(ResourceProperties.PROP_DISPLAY_NAME)),
id = Validator.escapeResourceName(id);
id = Validator.escapeResourceName(id);