public static void checkForMaximumCSSResources (final int nCSSExternals) { // Sources: // http://acidmartin.wordpress.com/2008/11/25/the-32-external-css-files-limitation-of-internet-explorer-and-more/ // http://social.msdn.microsoft.com/Forums/en-US/iewebdevelopment/thread/ad1b6e88-bbfa-4cc4-9e95-3889b82a7c1d if (nCSSExternals > MAX_CSS_IE) consistencyError ("You are including more than 31 CSS files (" + nCSSExternals + ") in your request, which will be ignored by Internet Explorer (at least up to version 8)!"); } }
@OverrideOnDemand protected void emitCSS (@Nonnull final IMicroElement eHead, @Nonnull final IHCConversionSettingsToNode aConversionSettings) { int nCSSExternals = 0; for (final IHCNode aCSS : m_aCSS) { if (aCSS instanceof HCLink) ++nCSSExternals; eHead.appendChild (aCSS.convertToMicroNode (aConversionSettings)); } if (aConversionSettings.areConsistencyChecksEnabled ()) { // This check must be done here because not all elements where available // at the time of regular consistency checking HCConsistencyChecker.checkForMaximumCSSResources (nCSSExternals); } }
@Override protected void onConsistencyCheck (@Nonnull final IHCConversionSettingsToNode aConversionSettings) { super.onConsistencyCheck (aConversionSettings); if (m_aData == null && m_aType == null) HCConsistencyChecker.consistencyError ("OBJECT contains neither type nor data"); }
private final void _ensureNodeState (@Nonnull final EHCNodeState eNodeState) { ValueEnforcer.notNull (eNodeState, "NodeState"); if (false) if (!m_eNodeState.equals (eNodeState)) HCConsistencyChecker.consistencyError ("Expected node state " + eNodeState + " but having node state " + m_eNodeState + " in " + toString ()); }
@Override protected void onConsistencyCheck (@Nonnull final IHCConversionSettingsToNode aConversionSettings) { super.onConsistencyCheck (aConversionSettings); if (HCHTMLHelper.recursiveContainsChildWithTagName (this, EHTMLElement.A)) HCConsistencyChecker.consistencyError ("<A> may never contain other links!"); if (HCHTMLHelper.recursiveContainsChildWithTagName (this, EHTMLElement.SELECT)) HCConsistencyChecker.consistencyError ("<A> contains invalid child element!"); }
@Nonnull public final IMPLTYPE setID (@Nullable final String sID, final boolean bImSureToOverwriteAnExistingID) { if (!bImSureToOverwriteAnExistingID && m_sID != null) if (StringHelper.hasText (sID)) { if (!m_sID.equals (sID)) HCConsistencyChecker.consistencyError ("Overwriting HC object ID '" + m_sID + "' with '" + sID + "' - this may have side effects!"); } else { HCConsistencyChecker.consistencyError ("The HC object ID '" + m_sID + "' will be removed - this may have side effects"); } m_sID = sID; return thisAsT (); }
@Nonnull public final IMPLTYPE setID (@Nullable final String sID, final boolean bImSureToOverwriteAnExistingID) { if (!bImSureToOverwriteAnExistingID && m_sID != null) if (StringHelper.hasText (sID)) { if (!m_sID.equals (sID)) HCConsistencyChecker.consistencyError ("Overwriting HC object ID '" + m_sID + "' with '" + sID + "' - this may have side effects!"); } else { HCConsistencyChecker.consistencyError ("The HC object ID '" + m_sID + "' will be removed - this may have side effects"); } m_sID = sID; return thisAsT (); }
@Override protected void onConsistencyCheck (@Nonnull final IHCConversionSettingsToNode aConversionSettings) { super.onConsistencyCheck (aConversionSettings); if (HCHTMLHelper.recursiveContainsChildWithTagName (this, EHTMLElement.METER)) HCConsistencyChecker.consistencyError ("METER contains other nested meter"); }
@Override protected void onConsistencyCheck (@Nonnull final IHCConversionSettingsToNode aConversionSettings) { super.onConsistencyCheck (aConversionSettings); if (HCHTMLHelper.recursiveContainsChildWithTagName (this, EHTMLElement.PROGRESS)) HCConsistencyChecker.consistencyError ("PROGRESS contains other nested progress"); }
public static void checkIfStringURLIsEscaped (@Nullable final String sHref) { if (StringHelper.hasText (sHref)) { // This is potential vulnerability. If the passed href is passed // from a user input, which cannot be told at this point, it might as well // contain a'&' followed by some malicious code that should be // escaped. // Note PH: this is not a vulnerability. This is a programming error! if (sHref.contains ("&")) consistencyError ("The URL '" + sHref + "' seems to be already XML escaped - please use an unescaped URL!!"); // Check if string is URL escaped final URLParameterDecoder aDecoder = new URLParameterDecoder (URLHelper.CHARSET_URL_OBJ); final String sDecoded = aDecoder.getDecoded (sHref); if (!sHref.equals (sDecoded)) consistencyError ("The URL '" + sHref + "' seems to be already URL encoded - please use a decoded URL!!"); } }
@Override protected void onConsistencyCheck (@Nonnull final IHCConversionSettingsToNode aConversionSettings) { super.onConsistencyCheck (aConversionSettings); if (HCHTMLHelper.recursiveContainsChildWithTagName (this, EHTMLElement.FORM)) HCConsistencyChecker.consistencyError ("FORM contains other nested form"); }
private static void _checkDeprecation (final Class <?> aElementClass, final String sElementName, final EHTMLVersion eHTMLVersion) { if (eHTMLVersion.isAtLeastHTML5 ()) { // HTML5 specifics checks if (s_aAUC_D_HTML5.hasAnnotation (aElementClass)) HCConsistencyChecker.consistencyError ("The element '" + sElementName + "' is deprecated in HTML5"); } else { // pre-HTML5 checks if (s_aAUC_S_HTML5.hasAnnotation (aElementClass)) HCConsistencyChecker.consistencyError ("The element '" + sElementName + "' is only available in HTML5"); } }
/** * Change the node state internally. Handle with care! * * @param eNodeState * The new node state. May not be <code>null</code>. */ public final void internalSetNodeState (@Nonnull final EHCNodeState eNodeState) { ValueEnforcer.notNull (eNodeState, "NodeState"); if (m_eNodeState.isAfter (eNodeState)) HCConsistencyChecker.consistencyError ("The new node state is invalid. Got " + eNodeState + " but having " + m_eNodeState); m_eNodeState = eNodeState; }
@Override protected void onConsistencyCheck (@Nonnull final IHCConversionSettingsToNode aConversionSettings) { super.onConsistencyCheck (aConversionSettings); final IHCElement <?> aChild = HCHTMLHelper.recursiveGetFirstChildWithTagName (this, EHTMLElement.IMG, EHTMLElement.OBJECT, EHTMLElement.SMALL, EHTMLElement.SUB, EHTMLElement.SUP); if (aChild != null) HCConsistencyChecker.consistencyError ("PRE elements contains forbidden tag " + aChild.getElement ()); } }
HCConsistencyChecker.consistencyError ("Overwriting HC object ID '" + m_sID + "' with '" + HCConsistencyChecker.consistencyError ("The HC object ID '" + m_sID + "' will be removed - this may have side effects");
@Override protected void onConsistencyCheck (@Nonnull final IHCConversionSettingsToNode aConversionSettings) { super.onConsistencyCheck (aConversionSettings); final IHCElement <?> aChild = HCHTMLHelper.recursiveGetFirstChildWithTagName (this, EHTMLElement.A, EHTMLElement.INPUT, EHTMLElement.SELECT, EHTMLElement.TEXTAREA, EHTMLElement.LABEL, EHTMLElement.BUTTON, EHTMLElement.FORM, EHTMLElement.FIELDSET, EHTMLElement.IFRAME); if (aChild != null) HCConsistencyChecker.consistencyError ("BUTTON element contains forbidden tag " + aChild.getElement ()); }
@Override protected void onConsistencyCheck (@Nonnull final IHCConversionSettingsToNode aConversionSettings) { final EHTMLVersion eHTMLVersion = aConversionSettings.getHTMLVersion (); // Deprecation is checked for all elements _checkDeprecation (getClass (), getTagName (), eHTMLVersion); if (eHTMLVersion.isAtLeastHTML5 ()) { if (m_aCustomAttrs != null) for (final Map.Entry <String, String> aEntry : m_aCustomAttrs.entrySet ()) { final String sAttrName = aEntry.getKey (); // Link element often contains arbitrary attributes if (!StringHelper.startsWith (sAttrName, CHTMLAttributes.HTML5_PREFIX_DATA) && !StringHelper.startsWith (sAttrName, CHTMLAttributes.PREFIX_ARIA) && m_eElement != EHTMLElement.LINK) { HCConsistencyChecker.consistencyError ("Custom HTML5 attribute '" + sAttrName + "' does not start with one of the proposed prefixes '" + CHTMLAttributes.HTML5_PREFIX_DATA + "' or '" + CHTMLAttributes.PREFIX_ARIA + "'"); } } } }
@Override protected void onConsistencyCheck (@Nonnull final IHCConversionSettingsToNode aConversionSettings) { super.onConsistencyCheck (aConversionSettings); final ICommonsSet <String> aUsedIDs = new CommonsHashSet <> (); HCHelper.iterateTree (this, (aParentNode, aChildNode) -> { if (aChildNode instanceof IHCHasID <?>) { final IHCHasID <?> aElement = (IHCHasID <?>) aChildNode; final String sID = aElement.getID (); if (StringHelper.hasText (sID) && !aUsedIDs.add (sID)) { HCConsistencyChecker.consistencyError ("The ID '" + sID + "' is used more than once within a single HTML page!"); } } return EFinish.UNFINISHED; }); }
@Override @OverrideOnDemand @OverridingMethodsMustInvokeSuper protected void fillMicroElement (@Nonnull final IMicroElement aElement, @Nonnull final IHCConversionSettingsToNode aConversionSettings) { super.fillMicroElement (aElement, aConversionSettings); if (aConversionSettings.areConsistencyChecksEnabled ()) { // Anything besides script may not be added besides the 2 default elements // from the ctor if (getChildCount () >= 2) for (int i = 2; i < getChildCount (); ++i) { final IHCNode aChild = getChildAtIndex (i); if (!HCSpecialNodeHandler.isOutOfBandNode (aChild)) HCConsistencyChecker.consistencyError ("A BootstrapDropdown must have only 2 children or scripts!"); } } }
HCConsistencyChecker.consistencyError (sContext + " row #" + (nRowIndex + 1) +