@Override public Position getContentPosition() { return getPosition(innerElement.getContent()); } }
@Override public Position getContentPosition() { return getPosition(innerElement.getContent()); } }
public static Span getContentSpan(Element e) { return getSpan(e.getContent()); }
@Override public void element(final Element element, final Context context, final BugList bugs) { final String tagName = element.getName(); if (tagName.equals(CF.CFQUERY)) { String queryGuts = element.getContent().toString().replaceAll("\\s+", ""); queryGuts = queryGuts.toLowerCase(); if (queryGuts.contains(selectStar)) { context.addMessage("SQL_SELECT_STAR", null); } } } }
@Override public void element(final Element element, final Context context, final BugList bugs) { final String tagName = element.getName(); if (tagName.equals(CF.CFQUERY)) { String queryGuts = element.getContent().toString().replaceAll("\\s+", ""); queryGuts = queryGuts.toLowerCase(); if (queryGuts.contains(selectStar)) { context.addMessage("SQL_SELECT_STAR", null); } } } }
@Override public void element(final Element element, final Context context, final BugList bugs) { final String elementName = element.getName(); if (elementName.equals(CF.CFCOMPONENT)) { // this includes whitespace-change it final int total = element.getContent().toString().split("\\n").length; checkSize(LENGTH_THRESHOLD, "EXCESSIVE_COMPONENT_LENGTH", context, 1, 0, total, bugs); } } }
private static String getOptionLabel(final Element optionElement) { final String labelAttributeValue=optionElement.getAttributeValue("label"); if (labelAttributeValue!=null) return labelAttributeValue; return CharacterReference.decodeCollapseWhiteSpace(optionElement.getContent()); } private final class OptionElementIterator implements Iterator<Element> {
@Override public void element(final Element element, final Context context, final BugList bugs) { final String elementName = element.getName(); if (elementName.equals(CF.CFCOMPONENT)) { // this includes whitespace-change it final int total = element.getContent().toString().split("\\n").length; checkSize(LENGTH_THRESHOLD, "EXCESSIVE_COMPONENT_LENGTH", context, 1, 0, total, bugs); } } }
private String getValue() { return (value==UNCHANGED) ? CharacterReference.decode(getElement().getContent()) : value; } }
private String processScopedCss(Source doc) { final String[] scopedCss = new String[1]; doc.getAllElements().stream() .filter(TemplateParser::isScopedStyleElement) .peek(styleScoped -> { String css = styleScoped.getContent().toString().trim(); if (!css.isEmpty()) { String lang = styleScoped.getAttributeValue("lang"); if ("scss".equalsIgnoreCase(lang)) { // lang="scss" css = scssToCss(css); } TemplateScopedCssParser scopedCssParser = new TemplateScopedCssParser(messager); Optional<ScopedCssResult> scopedCssResult = scopedCssParser.parse( context.getComponentTypeElement(), css); if (scopedCssResult.isPresent()) { context.getMandatoryAttributes().putAll(scopedCssResult.get().mandatoryAttributes); scopedCss[0] = scopedCssResult.get().scopedCss; } } }) .forEach(outputDocument::remove); return scopedCss[0]; }
private String getReturnValue(Element element) throws ZestAssignFailException { if (returnElement) { return element.getContent().toString(); } else if (returnAttribute) { return element.getAttributeValue(returnedAttributeName); } else { throw new ZestAssignFailException(this, "A selection method must be configured"); } }
@Override public void element(final Element element, final Context context, final BugList bugs) { if ( element.getName().equalsIgnoreCase(CF.CFQUERY) && !CF.QUERY.equalsIgnoreCase(element.getAttributeValue(CF.DBTYPE))) { String content = element.getContent().toString(); //Todo : cfparser/Jericho does not support parsing out the cfqueryparam very well. // the following code will not work when there is a > sign in the expression content = content.replaceAll("<[cC][fF][qQ][uU][eE][rR][yY][pP][aA][rR][aA][mM][^>]*>", ""); if (content.indexOf('#') >= 0) { final List<Integer> ignoreLines = determineIgnoreLines(element); final Matcher matcher = Pattern.compile("#(?:##)?([^#]+)(?:##)?#($|[^#])",Pattern.DOTALL).matcher(content); while (matcher.find()) { if (matcher.groupCount() >= 1) { int currentline = context.startLine() + countNewLinesUpTo(content, matcher.start()); int currentOffset = element.getStartTag().getEnd() + 1 + matcher.start(); final String variableName = matcher.group(1); if (!ignoreLines.contains(currentline)) { context.addMessage("CFQUERYPARAM_REQ", variableName, currentline, currentOffset); } } } } } }
@Override public void element(final Element element, final Context context, final BugList bugs) { if ( element.getName().equalsIgnoreCase(CF.CFQUERY) && !CF.QUERY.equalsIgnoreCase(element.getAttributeValue(CF.DBTYPE))) { String content = element.getContent().toString(); //Todo : cfparser/Jericho does not support parsing out the cfqueryparam very well. // the following code will not work when there is a > sign in the expression content = content.replaceAll("<[cC][fF][qQ][uU][eE][rR][yY][pP][aA][rR][aA][mM][^>]*>", ""); if (content.indexOf('#') >= 0) { final List<Integer> ignoreLines = determineIgnoreLines(element); final Matcher matcher = Pattern.compile("#(?:##)?([^#]+)(?:##)?#($|[^#])",Pattern.DOTALL).matcher(content); while (matcher.find()) { if (matcher.groupCount() >= 1) { int currentline = context.startLine() + countNewLinesUpTo(content, matcher.start()); int currentOffset = element.getStartTag().getEnd() + 1 + matcher.start(); final String variableName = matcher.group(1); if (!ignoreLines.contains(currentline)) { context.addMessage("CFQUERYPARAM_REQ", variableName, currentline, currentOffset); } } } } } }
public void process(Processor x, Element element) throws IOException { if (!x.includeHyperlinkURLs) { x.appendElementContent(element); return; } String renderedHyperlinkURL=x.renderer.renderHyperlinkURL(element.getStartTag()); if (renderedHyperlinkURL==null) { x.appendElementContent(element); return; } String href=element.getAttributeValue("href"); final boolean displayContent=href==null || !getInformalURL(href).equals(getInformalURL(element.getContent().toString())); // only display the content if it is not the same as the URL int linkLength=renderedHyperlinkURL.length(); if (displayContent) { x.appendElementContent(element); linkLength++; // allow for space after content } if (x.maxLineLength>0 && x.col+linkLength>=x.maxLineLength) { x.startNewLine(0); } else if (displayContent) { x.append(' '); } x.append(renderedHyperlinkURL); x.lastCharWhiteSpace=true; } }
public SelectFormControl(final Element element) { super(element,element.getAttributes().get(Attribute.MULTIPLE)!=null ? FormControlType.SELECT_MULTIPLE : FormControlType.SELECT_SINGLE,false); final List<Element> optionElements=element.getAllElements(HTMLElementName.OPTION); optionElementContainers=new ElementContainer[optionElements.size()]; int x=0; for (Element optionElement : optionElements) { final ElementContainer optionElementContainer=new ElementContainer(optionElement,true); if (optionElementContainer.predefinedValue==null) // use the content of the element if it has no value attribute optionElementContainer.predefinedValue=CharacterReference.decodeCollapseWhiteSpace(optionElementContainer.element.getContent()); optionElementContainers[x++]=optionElementContainer; } } public String getPredefinedValue() {
continue; for (StartTag texTag : tag.getElement().getContent().getAllStartTags(TEX_TAG_NAME)) { Element texElement = texTag.getElement(); if (texElement.getEndTag() == null) { String content = texElement.getContent().toString().trim(); Pair<Integer, Integer> bounds = getBounds(content); if(bounds.getRight() == 0){ logger.info("Empty source in Tex tag"); outputDocument.replace(texElement.getContent(), StringUtils.EMPTY); } else { String strippedContent = content.substring(bounds.getLeft(), bounds.getRight()); String unescapedContent = StringEscapeUtils.unescapeHtml4(strippedContent); outputDocument.replace(texElement.getContent(), unescapedContent);
public Pair<Integer, String> getBodyText() { Segment content = innerElement.getContent(); Integer lineNum = innerElement.getSource().getRow(content.getBegin()); String nl = content.getSource().getNewLine(); String body = nl==null? content.toString(): content.toString().replace(nl, "\n"); return Pair.make(lineNum, body); }
public Pair<Integer, String> getBodyText() { Segment content = innerElement.getContent(); Integer lineNum = innerElement.getSource().getRow(content.getBegin()); String nl = content.getSource().getNewLine(); String body = nl==null? content.toString(): content.toString().replace(nl, "\n"); return Pair.make(lineNum, body); }
public static List<Segment> getStyleURISegments(final Segment segment) { if (segment==null || segment.length()==0) return Collections.emptyList(); if (segment.getFirstStartTag()==null) { // no start tags in this segment, assume the segment is a style attribute value int urlDelimiterStartPos=segment.getSource().getParseText().indexOf("url(",segment.getBegin(),segment.getEnd()); if (urlDelimiterStartPos==-1) return Collections.emptyList(); return addURLSegmentsFromCSS(new ArrayList<Segment>(),new Segment(segment.getSource(),urlDelimiterStartPos,segment.getEnd())); } List<Segment> uriSegments=new ArrayList<Segment>(); for (StartTag startTag : segment.getAllStartTags("style",null)) { addURLSegmentsFromCSS(uriSegments,startTag.getAttributes().get("style").getValueSegment()); } for (Element element : segment.getAllElements(HTMLElementName.STYLE)) { addURLSegmentsFromCSS(uriSegments,element.getContent()); } Collections.sort(uriSegments); return uriSegments; }
void replaceInOutputDocument(final OutputDocument outputDocument) { if (outputStyle==FormControlOutputStyle.REMOVE) { outputDocument.remove(getElement()); } else if (outputStyle==FormControlOutputStyle.DISPLAY_VALUE) { outputDocument.replace(getElement(),getDisplayValueHTML(getValue(),true)); } else { replaceAttributesInOutputDocumentIfModified(outputDocument); if (value!=UNCHANGED) outputDocument.replace(getElement().getContent(),CharacterReference.encode(value,false)); } } private String getValue() {