@Override public void element(final Element element, final Context context, final BugList bugs) { if ("script".equals(element.getName())) { final String src = element.getStartTag().toString(); if (!src.matches(".*src=.*")) { context.addMessage("AVOID_USING_INLINE_JS", null); } } } }
@Override public void element(final Element element, final Context context, final BugList bugs) { if ("script".equals(element.getName())) { final String src = element.getStartTag().toString(); if (!src.matches(".*src=.*")) { context.addMessage("AVOID_USING_INLINE_JS", null); } } } }
private void processStartTag( StartTag tag ) { if( "<".equals( tag.getTagType().getStartDelimiter() ) ) { Element e = document.createElement( tag.getNameSegment().toString() ); stack.push( new Level( tag ) ); writer.write( "<" ); writer.write( tag.getNameSegment().toString() ); Attributes attributes = tag.getAttributes(); if( !attributes.isEmpty() ) { for( Attribute attribute : attributes ) { processAttribute( attribute ); } } if( tag.toString().trim().endsWith( "/>" ) || tag.isEmptyElementTag() ) { stack.pop(); writer.write( "/>" ); } else { writer.write( ">" ); } } else { writer.write( tag.toString() ); } }
private void processStartTag( StartTag tag ) { if( "<".equals( tag.getTagType().getStartDelimiter() ) ) { stack.push( new Level( tag ) ); writer.write( "<" ); writer.write( tag.getNameSegment().toString() ); Attributes attributes = tag.getAttributes(); if( !attributes.isEmpty() ) { for( Attribute attribute : attributes ) { processAttribute( attribute ); } } if( tag.toString().trim().endsWith( "/>" ) || tag.isEmptyElementTag() ) { stack.pop(); writer.write( "/>" ); } else { writer.write( ">" ); } } else { writer.write( tag.toString() ); } }
@Override public void element(final Element element, final Context context, final BugList bugs) { boolean encourageUpper = true; if (context.getConfiguration().getParameter(this,"PreferCase") != null) { try { encourageUpper = "upper".equalsIgnoreCase(context.getConfiguration().getParameter(this,"PreferCase")); } catch (final Exception e) { } } final String tag = element.getStartTag().toString(); if ("cf".equalsIgnoreCase(tag.substring(1, 3))) { int index = tag.indexOf(' '); if (index == -1) { index = tag.indexOf('>'); } final String cfTag = tag.substring(1, index); final String nonPreferredCase = encourageUpper ? cfTag.toLowerCase() : cfTag.toUpperCase(); /* * ensuring the tag is not pure uppercase instead of checking to see * if the tag is lowercase or camelcase as some camelcase can get * hairy e.g. <cfmcGrabURLFromHTTPSite> */ if (cfTag.equals(nonPreferredCase)) { final int begLine = element.getSource().getRow(element.getBegin()); context.addMessage(CFTAG_PREFERRED_CASE, cfTag, this, begLine, element.getBegin()); } } } }
@Override public void element(final Element element, final Context context, final BugList bugs) { boolean encourageUpper = true; if (context.getConfiguration().getParameter(this,"PreferCase") != null) { try { encourageUpper = "upper".equalsIgnoreCase(context.getConfiguration().getParameter(this,"PreferCase")); } catch (final Exception e) { } } final String tag = element.getStartTag().toString(); if ("cf".equalsIgnoreCase(tag.substring(1, 3))) { int index = tag.indexOf(' '); if (index == -1) { index = tag.indexOf('>'); } final String cfTag = tag.substring(1, index); final String nonPreferredCase = encourageUpper ? cfTag.toLowerCase() : cfTag.toUpperCase(); /* * ensuring the tag is not pure uppercase instead of checking to see * if the tag is lowercase or camelcase as some camelcase can get * hairy e.g. <cfmcGrabURLFromHTTPSite> */ if (cfTag.equals(nonPreferredCase)) { final int begLine = element.getSource().getRow(element.getBegin()); context.addMessage(CFTAG_PREFERRED_CASE, cfTag, this, begLine, element.getBegin()); } } } }
if (attributes==null || attributes.containsServerTagOutsideOfAttributeValue) return toString(); final StringBuilder sb=new StringBuilder(); sb.append('<');
startTextUnit(new GenericSkeleton(tag.toString()), propertyTextUnitPlaceholders); } else { if (!tag.isSyntacticalEmptyElementTag()) { startTextUnit(new GenericSkeleton(tag.toString())); } else { addToDocumentPart(tag.toString()); case GROUP_ELEMENT: if (propertyTextUnitPlaceholders != null && !propertyTextUnitPlaceholders.isEmpty()) { startGroup(new GenericSkeleton(tag.toString()), getConfig().getElementType(tag), getSrcLoc(), propertyTextUnitPlaceholders); } else { if (!tag.isSyntacticalEmptyElementTag()) { startGroup(new GenericSkeleton(tag.toString()), getConfig().getElementType(tag)); } else { addToDocumentPart(tag.toString()); default: if (propertyTextUnitPlaceholders != null && !propertyTextUnitPlaceholders.isEmpty()) { startDocumentPart(tag.toString(), tag.getName(), propertyTextUnitPlaceholders); endDocumentPart(); } else { addToDocumentPart(tag.toString());
} else { writer.write(st.toString());
final String getDocumentSpecifiedEncoding(EncodingDetector encodingDetector) { if (documentSpecifiedEncoding!=UNINITIALISED) return documentSpecifiedEncoding; final Tag xmlDeclarationTag=getTagAt(0); if (xmlDeclarationTag!=null && xmlDeclarationTag.getTagType()==StartTagType.XML_DECLARATION) { documentSpecifiedEncoding=((StartTag)xmlDeclarationTag).getAttributeValue("encoding"); if (documentSpecifiedEncoding!=null) return setEncoding(documentSpecifiedEncoding,xmlDeclarationTag.toString()); } // Check meta tags: for (StartTag metaTag : getAllStartTags(HTMLElementName.META)) { documentSpecifiedEncoding=metaTag.getAttributeValue("charset"); if (documentSpecifiedEncoding==null) { if (!"content-type".equalsIgnoreCase(metaTag.getAttributeValue("http-equiv"))) continue; final String contentValue=metaTag.getAttributeValue("content"); if (contentValue==null) continue; documentSpecifiedEncoding=getCharsetParameterFromHttpHeaderValue(contentValue); if (encodingDetector!=null && encodingDetector.isIncompatibleWithPreliminaryEncoding(documentSpecifiedEncoding)) continue; } if (documentSpecifiedEncoding!=null) return setEncoding(documentSpecifiedEncoding,metaTag.toString()); } return setEncoding(null,"No encoding specified in document"); }
scanElement(elem, context); final Pattern p = Pattern.compile("<\\w+\\s(.*[^/])/?>", Pattern.MULTILINE | Pattern.DOTALL); final String expr = elem.getFirstStartTag().toString(); final Matcher m = p.matcher(expr); if (m.matches()) {
scanElement(elem, context); final Pattern p = Pattern.compile("<\\w+\\s(.*[^/])/?>", Pattern.MULTILINE | Pattern.DOTALL); final String expr = elem.getFirstStartTag().toString(); final Matcher m = p.matcher(expr); if (m.matches()) {