├── .gitignore ├── .slather.yml ├── .travis.yml ├── HTMLPurifier-Prefix.gcda ├── HTMLPurifier-Prefix.gcno ├── HTMLPurifier.podspec ├── HTMLPurifier.xcodeproj ├── project.pbxproj ├── project.xcworkspace │ └── contents.xcworkspacedata └── xcshareddata │ └── xcschemes │ ├── HTMLPurifier.xcscheme │ ├── HTMLPurifierTests.xcscheme │ └── HTMLPurifieriOS.xcscheme ├── HTMLPurifier ├── Attributes │ ├── AttrDef │ │ ├── CSS │ │ │ ├── HTMLPurifier_AttrDef_CSS.h │ │ │ ├── HTMLPurifier_AttrDef_CSS.m │ │ │ ├── HTMLPurifier_AttrDef_CSS_AlphaValue.h │ │ │ ├── HTMLPurifier_AttrDef_CSS_AlphaValue.m │ │ │ ├── HTMLPurifier_AttrDef_CSS_Background.h │ │ │ ├── HTMLPurifier_AttrDef_CSS_Background.m │ │ │ ├── HTMLPurifier_AttrDef_CSS_BackgroundPosition.h │ │ │ ├── HTMLPurifier_AttrDef_CSS_BackgroundPosition.m │ │ │ ├── HTMLPurifier_AttrDef_CSS_Border.h │ │ │ ├── HTMLPurifier_AttrDef_CSS_Border.m │ │ │ ├── HTMLPurifier_AttrDef_CSS_BorderRadius.h │ │ │ ├── HTMLPurifier_AttrDef_CSS_BorderRadius.m │ │ │ ├── HTMLPurifier_AttrDef_CSS_Color.h │ │ │ ├── HTMLPurifier_AttrDef_CSS_Color.m │ │ │ ├── HTMLPurifier_AttrDef_CSS_Composite.h │ │ │ ├── HTMLPurifier_AttrDef_CSS_Composite.m │ │ │ ├── HTMLPurifier_AttrDef_CSS_DenyElementDecorator.h │ │ │ ├── HTMLPurifier_AttrDef_CSS_DenyElementDecorator.m │ │ │ ├── HTMLPurifier_AttrDef_CSS_Filter.h │ │ │ ├── HTMLPurifier_AttrDef_CSS_Filter.m │ │ │ ├── HTMLPurifier_AttrDef_CSS_Font.h │ │ │ ├── HTMLPurifier_AttrDef_CSS_Font.m │ │ │ ├── HTMLPurifier_AttrDef_CSS_FontFamily.h │ │ │ ├── HTMLPurifier_AttrDef_CSS_FontFamily.m │ │ │ ├── HTMLPurifier_AttrDef_CSS_Ident.h │ │ │ ├── HTMLPurifier_AttrDef_CSS_Ident.m │ │ │ ├── HTMLPurifier_AttrDef_CSS_ImportantDecorator.h │ │ │ ├── HTMLPurifier_AttrDef_CSS_ImportantDecorator.m │ │ │ ├── HTMLPurifier_AttrDef_CSS_Length.h │ │ │ ├── HTMLPurifier_AttrDef_CSS_Length.m │ │ │ ├── HTMLPurifier_AttrDef_CSS_ListStyle.h │ │ │ ├── HTMLPurifier_AttrDef_CSS_ListStyle.m │ │ │ ├── HTMLPurifier_AttrDef_CSS_Multiple.h │ │ │ ├── HTMLPurifier_AttrDef_CSS_Multiple.m │ │ │ ├── HTMLPurifier_AttrDef_CSS_Number.h │ │ │ ├── HTMLPurifier_AttrDef_CSS_Number.m │ │ │ ├── HTMLPurifier_AttrDef_CSS_Outline.h │ │ │ ├── HTMLPurifier_AttrDef_CSS_Outline.m │ │ │ ├── HTMLPurifier_AttrDef_CSS_Percentage.h │ │ │ ├── HTMLPurifier_AttrDef_CSS_Percentage.m │ │ │ ├── HTMLPurifier_AttrDef_CSS_Shape.h │ │ │ ├── HTMLPurifier_AttrDef_CSS_Shape.m │ │ │ ├── HTMLPurifier_AttrDef_CSS_TextDecoration.h │ │ │ ├── HTMLPurifier_AttrDef_CSS_TextDecoration.m │ │ │ ├── HTMLPurifier_AttrDef_CSS_URI.h │ │ │ └── HTMLPurifier_AttrDef_CSS_URI.m │ │ ├── HTML │ │ │ ├── HTMLPurifier_AttrDef_HTML_Bool.h │ │ │ ├── HTMLPurifier_AttrDef_HTML_Bool.m │ │ │ ├── HTMLPurifier_AttrDef_HTML_Class.h │ │ │ ├── HTMLPurifier_AttrDef_HTML_Class.m │ │ │ ├── HTMLPurifier_AttrDef_HTML_Color.h │ │ │ ├── HTMLPurifier_AttrDef_HTML_Color.m │ │ │ ├── HTMLPurifier_AttrDef_HTML_FrameTarget.h │ │ │ ├── HTMLPurifier_AttrDef_HTML_FrameTarget.m │ │ │ ├── HTMLPurifier_AttrDef_HTML_ID.h │ │ │ ├── HTMLPurifier_AttrDef_HTML_ID.m │ │ │ ├── HTMLPurifier_AttrDef_HTML_Length.h │ │ │ ├── HTMLPurifier_AttrDef_HTML_Length.m │ │ │ ├── HTMLPurifier_AttrDef_HTML_LinkTypes.h │ │ │ ├── HTMLPurifier_AttrDef_HTML_LinkTypes.m │ │ │ ├── HTMLPurifier_AttrDef_HTML_MultiLength.h │ │ │ ├── HTMLPurifier_AttrDef_HTML_MultiLength.m │ │ │ ├── HTMLPurifier_AttrDef_HTML_Nmtokens.h │ │ │ ├── HTMLPurifier_AttrDef_HTML_Nmtokens.m │ │ │ ├── HTMLPurifier_AttrDef_HTML_Pixels.h │ │ │ └── HTMLPurifier_AttrDef_HTML_Pixels.m │ │ ├── HTMLPurifier_AttrDef.h │ │ ├── HTMLPurifier_AttrDef.m │ │ ├── HTMLPurifier_AttrDef_Clone.h │ │ ├── HTMLPurifier_AttrDef_Clone.m │ │ ├── HTMLPurifier_AttrDef_Enum.h │ │ ├── HTMLPurifier_AttrDef_Enum.m │ │ ├── HTMLPurifier_AttrDef_Integer.h │ │ ├── HTMLPurifier_AttrDef_Integer.m │ │ ├── HTMLPurifier_AttrDef_Lang.h │ │ ├── HTMLPurifier_AttrDef_Lang.m │ │ ├── HTMLPurifier_AttrDef_Switch.h │ │ ├── HTMLPurifier_AttrDef_Switch.m │ │ ├── HTMLPurifier_AttrDef_Text.h │ │ ├── HTMLPurifier_AttrDef_Text.m │ │ ├── HTMLPurifier_AttrDef_URI.h │ │ ├── HTMLPurifier_AttrDef_URI.m │ │ ├── HTMLPurifier_AttrDef_URI_Email.h │ │ ├── HTMLPurifier_AttrDef_URI_Email.m │ │ ├── HTMLPurifier_AttrDef_URI_Email_SimpleCheck.h │ │ ├── HTMLPurifier_AttrDef_URI_Email_SimpleCheck.m │ │ ├── HTMLPurifier_AttrDef_URI_Host.h │ │ ├── HTMLPurifier_AttrDef_URI_Host.m │ │ ├── HTMLPurifier_AttrDef_URI_IPv4.h │ │ ├── HTMLPurifier_AttrDef_URI_IPv4.m │ │ ├── HTMLPurifier_AttrDef_URI_IPv6.h │ │ └── HTMLPurifier_AttrDef_URI_IPv6.m │ ├── AttrTransform │ │ ├── HTMLPurifier_AttrTransform.h │ │ ├── HTMLPurifier_AttrTransform.m │ │ ├── HTMLPurifier_AttrTransform_Background.h │ │ ├── HTMLPurifier_AttrTransform_Background.m │ │ ├── HTMLPurifier_AttrTransform_BdoDir.h │ │ ├── HTMLPurifier_AttrTransform_BdoDir.m │ │ ├── HTMLPurifier_AttrTransform_BgColor.h │ │ ├── HTMLPurifier_AttrTransform_BgColor.m │ │ ├── HTMLPurifier_AttrTransform_BoolToCSS.h │ │ ├── HTMLPurifier_AttrTransform_BoolToCSS.m │ │ ├── HTMLPurifier_AttrTransform_Border.h │ │ ├── HTMLPurifier_AttrTransform_Border.m │ │ ├── HTMLPurifier_AttrTransform_EnumToCSS.h │ │ ├── HTMLPurifier_AttrTransform_EnumToCSS.m │ │ ├── HTMLPurifier_AttrTransform_ImgRequired.h │ │ ├── HTMLPurifier_AttrTransform_ImgRequired.m │ │ ├── HTMLPurifier_AttrTransform_ImgSpace.h │ │ ├── HTMLPurifier_AttrTransform_ImgSpace.m │ │ ├── HTMLPurifier_AttrTransform_ImgTrackingRemoval.h │ │ ├── HTMLPurifier_AttrTransform_ImgTrackingRemoval.m │ │ ├── HTMLPurifier_AttrTransform_Input.h │ │ ├── HTMLPurifier_AttrTransform_Input.m │ │ ├── HTMLPurifier_AttrTransform_Lang.h │ │ ├── HTMLPurifier_AttrTransform_Lang.m │ │ ├── HTMLPurifier_AttrTransform_Length.h │ │ ├── HTMLPurifier_AttrTransform_Length.m │ │ ├── HTMLPurifier_AttrTransform_Name.h │ │ ├── HTMLPurifier_AttrTransform_Name.m │ │ ├── HTMLPurifier_AttrTransform_NameSync.h │ │ ├── HTMLPurifier_AttrTransform_NameSync.m │ │ ├── HTMLPurifier_AttrTransform_Nofollow.h │ │ ├── HTMLPurifier_AttrTransform_Nofollow.m │ │ ├── HTMLPurifier_AttrTransform_SafeEmbed.h │ │ ├── HTMLPurifier_AttrTransform_SafeEmbed.m │ │ ├── HTMLPurifier_AttrTransform_SafeObject.h │ │ ├── HTMLPurifier_AttrTransform_SafeObject.m │ │ ├── HTMLPurifier_AttrTransform_SafeParam.h │ │ ├── HTMLPurifier_AttrTransform_SafeParam.m │ │ ├── HTMLPurifier_AttrTransform_ScriptRequired.h │ │ ├── HTMLPurifier_AttrTransform_ScriptRequired.m │ │ ├── HTMLPurifier_AttrTransform_TargetBlank.h │ │ ├── HTMLPurifier_AttrTransform_TargetBlank.m │ │ ├── HTMLPurifier_AttrTransform_Textarea.h │ │ └── HTMLPurifier_AttrTransform_Textarea.m │ ├── HTMLPurifier_AttrCollections.h │ ├── HTMLPurifier_AttrCollections.m │ ├── HTMLPurifier_AttrTypes.h │ ├── HTMLPurifier_AttrTypes.m │ ├── HTMLPurifier_AttrValidator.h │ ├── HTMLPurifier_AttrValidator.m │ ├── HTMLPurifier_Length.h │ ├── HTMLPurifier_Length.m │ ├── HTMLPurifier_URI.h │ ├── HTMLPurifier_URI.m │ ├── HTMLPurifier_URIParser.h │ ├── HTMLPurifier_URIParser.m │ ├── HTMLPurifier_UnitConverter.h │ └── HTMLPurifier_UnitConverter.m ├── BasicPHP.h ├── BasicPHP.m ├── ChildDef & ElementDef │ ├── HTMLPurifier_ChildDef.h │ ├── HTMLPurifier_ChildDef.m │ ├── HTMLPurifier_ChildDef_Chameleon.h │ ├── HTMLPurifier_ChildDef_Chameleon.m │ ├── HTMLPurifier_ChildDef_Custom.h │ ├── HTMLPurifier_ChildDef_Custom.m │ ├── HTMLPurifier_ChildDef_Empty.h │ ├── HTMLPurifier_ChildDef_Empty.m │ ├── HTMLPurifier_ChildDef_List.h │ ├── HTMLPurifier_ChildDef_List.m │ ├── HTMLPurifier_ChildDef_Optional.h │ ├── HTMLPurifier_ChildDef_Optional.m │ ├── HTMLPurifier_ChildDef_Required.h │ ├── HTMLPurifier_ChildDef_Required.m │ ├── HTMLPurifier_ChildDef_StrictBlockquote.h │ ├── HTMLPurifier_ChildDef_StrictBlockquote.m │ ├── HTMLPurifier_ChildDef_Tables.h │ ├── HTMLPurifier_ChildDef_Tables.m │ ├── HTMLPurifier_ElementDef.h │ └── HTMLPurifier_ElementDef.m ├── Config & Context │ ├── HTMLPurifier_Config.h │ ├── HTMLPurifier_Config.m │ ├── HTMLPurifier_ConfigSchema.h │ ├── HTMLPurifier_ConfigSchema.m │ ├── HTMLPurifier_ContentSets.h │ ├── HTMLPurifier_ContentSets.m │ ├── HTMLPurifier_Context.h │ ├── HTMLPurifier_Context.m │ ├── HTMLPurifier_PropertyList.h │ └── HTMLPurifier_PropertyList.m ├── Definition │ ├── HTMLPurifier_CSSDefinition.h │ ├── HTMLPurifier_CSSDefinition.m │ ├── HTMLPurifier_Definition.h │ ├── HTMLPurifier_Definition.m │ ├── HTMLPurifier_DefinitionCache.h │ ├── HTMLPurifier_DefinitionCache.m │ ├── HTMLPurifier_DefinitionCacheFactory.h │ ├── HTMLPurifier_DefinitionCacheFactory.m │ ├── HTMLPurifier_HTMLDefinition.h │ ├── HTMLPurifier_HTMLDefinition.m │ ├── HTMLPurifier_URIDefinition.h │ └── HTMLPurifier_URIDefinition.m ├── Errors & Language │ ├── HTMLPurifier_ErrorCollector.h │ ├── HTMLPurifier_ErrorCollector.m │ ├── HTMLPurifier_Language.h │ ├── HTMLPurifier_Language.m │ ├── HTMLPurifier_LanguageFactory.h │ └── HTMLPurifier_LanguageFactory.m ├── ExportedSymbols.exp ├── HTMLModule │ ├── HTMLPurifier_HTMLModule.h │ ├── HTMLPurifier_HTMLModule.m │ ├── HTMLPurifier_HTMLModuleManager.h │ ├── HTMLPurifier_HTMLModuleManager.m │ ├── HTMLPurifier_HTMLModule_Bdo.h │ ├── HTMLPurifier_HTMLModule_Bdo.m │ ├── HTMLPurifier_HTMLModule_CommonAttributes.h │ ├── HTMLPurifier_HTMLModule_CommonAttributes.m │ ├── HTMLPurifier_HTMLModule_Edit.h │ ├── HTMLPurifier_HTMLModule_Edit.m │ ├── HTMLPurifier_HTMLModule_Forms.h │ ├── HTMLPurifier_HTMLModule_Forms.m │ ├── HTMLPurifier_HTMLModule_Hypertext.h │ ├── HTMLPurifier_HTMLModule_Hypertext.m │ ├── HTMLPurifier_HTMLModule_Image.h │ ├── HTMLPurifier_HTMLModule_Image.m │ ├── HTMLPurifier_HTMLModule_Legacy.h │ ├── HTMLPurifier_HTMLModule_Legacy.m │ ├── HTMLPurifier_HTMLModule_List.h │ ├── HTMLPurifier_HTMLModule_List.m │ ├── HTMLPurifier_HTMLModule_Name.h │ ├── HTMLPurifier_HTMLModule_Name.m │ ├── HTMLPurifier_HTMLModule_NonXMLCommonAttributes.h │ ├── HTMLPurifier_HTMLModule_NonXMLCommonAttributes.m │ ├── HTMLPurifier_HTMLModule_Object.h │ ├── HTMLPurifier_HTMLModule_Object.m │ ├── HTMLPurifier_HTMLModule_Presentation.h │ ├── HTMLPurifier_HTMLModule_Presentation.m │ ├── HTMLPurifier_HTMLModule_StyleAttribute.h │ ├── HTMLPurifier_HTMLModule_StyleAttribute.m │ ├── HTMLPurifier_HTMLModule_Tables.h │ ├── HTMLPurifier_HTMLModule_Tables.m │ ├── HTMLPurifier_HTMLModule_Text.h │ ├── HTMLPurifier_HTMLModule_Text.m │ ├── HTMLPurifier_HTMLModule_Tidy.h │ ├── HTMLPurifier_HTMLModule_Tidy.m │ ├── HTMLPurifier_HTMLModule_Tidy_XHTML.h │ ├── HTMLPurifier_HTMLModule_Tidy_XHTML.m │ ├── HTMLPurifier_HTMLModule_XMLCommonAttributes.h │ └── HTMLPurifier_HTMLModule_XMLCommonAttributes.m ├── HTMLPurifier.h ├── HTMLPurifier.m ├── Injector │ ├── HTMLPurifier_Injector.h │ ├── HTMLPurifier_Injector.m │ ├── HTMLPurifier_Injector_Linkify.h │ └── HTMLPurifier_Injector_Linkify.m ├── Node │ ├── HTMLPurifier_Node.h │ ├── HTMLPurifier_Node.m │ ├── HTMLPurifier_Node_Comment.h │ ├── HTMLPurifier_Node_Comment.m │ ├── HTMLPurifier_Node_Element.h │ ├── HTMLPurifier_Node_Element.m │ ├── HTMLPurifier_Node_Text.h │ └── HTMLPurifier_Node_Text.m ├── Parsing │ ├── HTMLPurifier_Arborize.h │ ├── HTMLPurifier_Arborize.m │ ├── HTMLPurifier_DOMNode.h │ ├── HTMLPurifier_DOMNode.m │ ├── HTMLPurifier_Doctype.h │ ├── HTMLPurifier_Doctype.m │ ├── HTMLPurifier_DoctypeRegistry.h │ ├── HTMLPurifier_DoctypeRegistry.m │ ├── HTMLPurifier_Encoder.h │ ├── HTMLPurifier_Encoder.m │ ├── HTMLPurifier_EntityLookup.h │ ├── HTMLPurifier_EntityLookup.m │ ├── HTMLPurifier_EntityParser.h │ ├── HTMLPurifier_EntityParser.m │ ├── HTMLPurifier_FlashStackObject.h │ ├── HTMLPurifier_FlashStackObject.m │ ├── HTMLPurifier_Generator.h │ ├── HTMLPurifier_Generator.m │ ├── HTMLPurifier_IDAccumulator.h │ ├── HTMLPurifier_IDAccumulator.m │ ├── HTMLPurifier_Lexer.h │ ├── HTMLPurifier_Lexer.m │ ├── HTMLPurifier_Lexer_libxmlLex.h │ ├── HTMLPurifier_Lexer_libxmlLex.m │ ├── HTMLPurifier_PercentEncoder.h │ ├── HTMLPurifier_PercentEncoder.m │ ├── HTMLPurifier_Queue.h │ ├── HTMLPurifier_Queue.m │ ├── HTMLPurifier_VarParser.h │ ├── HTMLPurifier_VarParser.m │ ├── HTMLPurifier_VarParser_Flexible.h │ ├── HTMLPurifier_VarParser_Flexible.m │ ├── HTMLPurifier_Zipper.h │ └── HTMLPurifier_Zipper.m ├── Strategy │ ├── HTMLPurifier_Strategy.h │ ├── HTMLPurifier_Strategy.m │ ├── HTMLPurifier_Strategy_Composite.h │ ├── HTMLPurifier_Strategy_Composite.m │ ├── HTMLPurifier_Strategy_Core.h │ ├── HTMLPurifier_Strategy_Core.m │ ├── HTMLPurifier_Strategy_FixNesting.h │ ├── HTMLPurifier_Strategy_FixNesting.m │ ├── HTMLPurifier_Strategy_MakeWellFormed.h │ ├── HTMLPurifier_Strategy_MakeWellFormed.m │ ├── HTMLPurifier_Strategy_RemoveForeignElements.h │ ├── HTMLPurifier_Strategy_RemoveForeignElements.m │ ├── HTMLPurifier_Strategy_ValidateAttributes.h │ └── HTMLPurifier_Strategy_ValidateAttributes.m ├── TagTransform │ ├── HTMLPurifier_TagTransform.h │ ├── HTMLPurifier_TagTransform.m │ ├── HTMLPurifier_TagTransform_Font.h │ ├── HTMLPurifier_TagTransform_Font.m │ ├── HTMLPurifier_TagTransform_Simple.h │ └── HTMLPurifier_TagTransform_Simple.m ├── Token │ ├── HTMLPurifier_Token.h │ ├── HTMLPurifier_Token.m │ ├── HTMLPurifier_TokenFactory.h │ ├── HTMLPurifier_TokenFactory.m │ ├── HTMLPurifier_Token_Comment.h │ ├── HTMLPurifier_Token_Comment.m │ ├── HTMLPurifier_Token_Empty.h │ ├── HTMLPurifier_Token_Empty.m │ ├── HTMLPurifier_Token_End.h │ ├── HTMLPurifier_Token_End.m │ ├── HTMLPurifier_Token_Start.h │ ├── HTMLPurifier_Token_Start.m │ ├── HTMLPurifier_Token_Tag.h │ ├── HTMLPurifier_Token_Tag.m │ ├── HTMLPurifier_Token_Text.h │ └── HTMLPurifier_Token_Text.m ├── URIFilter │ ├── HTMLPurifier_Filter.h │ ├── HTMLPurifier_Filter.m │ ├── HTMLPurifier_URIFilter.h │ ├── HTMLPurifier_URIFilter.m │ ├── HTMLPurifier_URIFilter_DisableExternal.h │ ├── HTMLPurifier_URIFilter_DisableExternal.m │ ├── HTMLPurifier_URIFilter_DisableExternalResources.h │ ├── HTMLPurifier_URIFilter_DisableExternalResources.m │ ├── HTMLPurifier_URIFilter_DisableResources.h │ ├── HTMLPurifier_URIFilter_DisableResources.m │ ├── HTMLPurifier_URIFilter_HostBlacklist.h │ ├── HTMLPurifier_URIFilter_HostBlacklist.m │ ├── HTMLPurifier_URIFilter_MakeAbsolute.h │ ├── HTMLPurifier_URIFilter_MakeAbsolute.m │ ├── HTMLPurifier_URIFilter_Munge.h │ ├── HTMLPurifier_URIFilter_Munge.m │ ├── HTMLPurifier_URIFilter_SafeIframe.h │ └── HTMLPurifier_URIFilter_SafeIframe.m └── URIScheme │ ├── HTMLPurifier_URIScheme.h │ ├── HTMLPurifier_URIScheme.m │ ├── HTMLPurifier_URISchemeRegistry.h │ ├── HTMLPurifier_URISchemeRegistry.m │ ├── HTMLPurifier_URIScheme_cid.h │ ├── HTMLPurifier_URIScheme_cid.m │ ├── HTMLPurifier_URIScheme_data.h │ ├── HTMLPurifier_URIScheme_data.m │ ├── HTMLPurifier_URIScheme_file.h │ ├── HTMLPurifier_URIScheme_file.m │ ├── HTMLPurifier_URIScheme_ftp.h │ ├── HTMLPurifier_URIScheme_ftp.m │ ├── HTMLPurifier_URIScheme_http.h │ ├── HTMLPurifier_URIScheme_http.m │ ├── HTMLPurifier_URIScheme_https.h │ ├── HTMLPurifier_URIScheme_https.m │ ├── HTMLPurifier_URIScheme_mailto.h │ ├── HTMLPurifier_URIScheme_mailto.m │ ├── HTMLPurifier_URIScheme_news.h │ ├── HTMLPurifier_URIScheme_news.m │ ├── HTMLPurifier_URIScheme_nntp.h │ └── HTMLPurifier_URIScheme_nntp.m ├── HTMLPurifierObjC ├── HTMLPurifierObjC-Prefix.pch ├── HTMLPurifierObjC.h └── HTMLPurifierObjC.m ├── HTMLPurifierObjCTests ├── HTMLPurifierObjCTests-Info.plist ├── HTMLPurifierObjCTests.m └── en.lproj │ └── InfoPlist.strings ├── HTMLPurifierTests ├── CSSTest.m ├── EntityParserTest.m ├── HTMLPurifierTests-Info.plist ├── HTMLPurifierTests.m ├── HTMLPurifier_AttrCollectionsTest.m ├── HTMLPurifier_AttrCollections_TestForConstruct.h ├── HTMLPurifier_AttrCollections_TestForConstruct.m ├── HTMLPurifier_AttrDefHarness.h ├── HTMLPurifier_AttrDefHarness.m ├── HTMLPurifier_AttrDef_EnumTest.m ├── HTMLPurifier_AttrDef_HTML_BoolTest.m ├── HTMLPurifier_AttrDef_HTML_ClassTest.m ├── HTMLPurifier_AttrDef_HTML_ColorTest.m ├── HTMLPurifier_AttrDef_HTML_FrameTargetTest.m ├── HTMLPurifier_AttrDef_HTML_IDTest.m ├── HTMLPurifier_AttrDef_HTML_LengthTest.m ├── HTMLPurifier_AttrDef_HTML_LinkTypesTest.m ├── HTMLPurifier_AttrDef_HTML_MultiLengthTest.m ├── HTMLPurifier_AttrDef_HTML_NmtokensTest.m ├── HTMLPurifier_AttrDef_HTML_PixelsTest.m ├── HTMLPurifier_AttrDef_IntegerTest.m ├── HTMLPurifier_AttrDef_LangTest.m ├── HTMLPurifier_AttrDef_SwitchTest.m ├── HTMLPurifier_AttrDef_TextTest.m ├── HTMLPurifier_AttrDef_URITest.m ├── HTMLPurifier_AttrDef_URI_Email_SimpleCheckTest.m ├── HTMLPurifier_AttrDef_URI_HostTest.m ├── HTMLPurifier_AttrDef_URI_IPv4Test.m ├── HTMLPurifier_AttrDef_URI_IPv6Test.m ├── HTMLPurifier_AttrTransformHarness.h ├── HTMLPurifier_AttrTransformHarness.m ├── HTMLPurifier_AttrTransformTest.m ├── HTMLPurifier_AttrTransform_BackgroundTest.m ├── HTMLPurifier_AttrTransform_BdoDirTest.m ├── HTMLPurifier_AttrTransform_ImgRequiredTest.m ├── HTMLPurifier_AttrTransform_NameSyncTest.m ├── HTMLPurifier_ChildDef_ChameleonTest.m ├── HTMLPurifier_ChildDef_CustomTest.m ├── HTMLPurifier_ChildDef_ListTest.m ├── HTMLPurifier_ChildDef_OptionalTest.m ├── HTMLPurifier_ChildDef_RequiredTest.m ├── HTMLPurifier_ChildDef_StrictBlockquoteTest.m ├── HTMLPurifier_ChildDef_TablesTest.m ├── HTMLPurifier_ConfigTest.m ├── HTMLPurifier_ElementDefTest.m ├── HTMLPurifier_EncoderTest.m ├── HTMLPurifier_HTMLModuleTest.m ├── HTMLPurifier_Harness.h ├── HTMLPurifier_Harness.m ├── HTMLPurifier_InjectorHarness.m ├── HTMLPurifier_LinkifyTest.m ├── HTMLPurifier_PercentEncoderTests.m ├── HTMLPurifier_RemoveForeignElementsTest.m ├── HTMLPurifier_Strategy_FixNestingTest.m ├── HTMLPurifier_Strategy_MakeWellFormedTest.m ├── HTMLPurifier_TokenFactoryTest.m ├── HTMLPurifier_TokenTest.m ├── HTMLPurifier_URIDefinitionTest.m ├── HTMLPurifier_URIFilterHarness.h ├── HTMLPurifier_URIFilterHarness.m ├── HTMLPurifier_URIFilter_DisableExternalResourcesTest.m ├── HTMLPurifier_URIFilter_DisableExternalTest.m ├── HTMLPurifier_URIFilter_DisableResourcesTest.m ├── HTMLPurifier_URIFilter_HostBlacklistTest.m ├── HTMLPurifier_URIFilter_MakeAbsoluteTest.m ├── HTMLPurifier_URIFilter_MungeTest.m ├── HTMLPurifier_URIHarness.h ├── HTMLPurifier_URIHarness.m ├── HTMLPurifier_URISchemeRegistryTest.m ├── HTMLPurifier_URISchemeTest.m ├── HTMLPurifier_URITest.m ├── HTMLPurifier_ZipperTest.m ├── PropertyListTest.m ├── Smoketest.m ├── URIParserTest.m ├── UnitConverterTest.m ├── ValidateAttributesTest.m ├── en.lproj │ └── InfoPlist.strings ├── orrickClean.html ├── orrickTest.html ├── outlookClean.html ├── outlookTest.html ├── test_Emails.plist └── zohoMailTest.html ├── HTMLPurifieriOS └── HTMLPurifieriOS-Prefix.pch ├── HTMLPurifieriOSTests ├── HTMLPurifieriOSTests-Info.plist └── en.lproj │ └── InfoPlist.strings ├── LICENSE ├── OCMock.framework ├── Headers ├── OCMock ├── Resources └── Versions │ ├── A │ ├── Headers │ │ ├── NSNotificationCenter+OCMAdditions.h │ │ ├── OCMArg.h │ │ ├── OCMConstraint.h │ │ ├── OCMock.h │ │ ├── OCMockObject.h │ │ └── OCMockRecorder.h │ ├── OCMock │ └── Resources │ │ ├── Info.plist │ │ └── en.lproj │ │ └── InfoPlist.strings │ └── Current ├── OCMock ├── NSNotificationCenter+OCMAdditions.h ├── OCMArg.h ├── OCMConstraint.h ├── OCMLocation.h ├── OCMMacroState.h ├── OCMRecorder.h ├── OCMStubRecorder.h ├── OCMock.h └── OCMockObject.h ├── ObjectiveC.gcda ├── ObjectiveC.gcno ├── README.md ├── Supporting Files ├── ExportedSymbols.exp ├── HTMLPurifier-Info.plist ├── HTMLPurifier-Prefix.pch ├── HTMLPurifierConfig.plist ├── InfoPlist.strings ├── entities.plist ├── xssAttacks.plist └── xssSmoketests.plist └── libOCMock.a /.gitignore: -------------------------------------------------------------------------------- 1 | # OS X 2 | .DS_Store 3 | 4 | # Xcode 5 | build/ 6 | *.pbxuser 7 | !default.pbxuser 8 | *.mode1v3 9 | !default.mode1v3 10 | *.mode2v3 11 | !default.mode2v3 12 | *.perspectivev3 13 | !default.perspectivev3 14 | xcuserdata 15 | *.xccheckout 16 | profile 17 | *.moved-aside 18 | DerivedData 19 | .idea/ 20 | *.hmap 21 | *.ipa 22 | 23 | #CocoaPods 24 | Pods 25 | -------------------------------------------------------------------------------- /.slather.yml: -------------------------------------------------------------------------------- 1 | ci_service: travis_ci 2 | coverage_service: coveralls 3 | xcodeproj: HTMLPurifier.xcodeproj 4 | source_directory: HTMLPurifier -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: objective-c 2 | 3 | xcode_project: HTMLPurifier.xcodeproj 4 | xcode_scheme: HTMLPurifieriOS 5 | 6 | 7 | before_install: 8 | - sudo easy_install cpp-coveralls 9 | - gem update xcodeproj 10 | - gem install slather 11 | 12 | install: 13 | - gem install xcpretty --no-rdoc --no-ri --no-document --quiet 14 | script: 15 | - pod lib lint --quick 16 | - xctool -project HTMLPurifier.xcodeproj -scheme HTMLPurifieriOS -sdk iphonesimulator8.1 clean test ONLY_ACTIVE_ARCH=NO GCC_INSTRUMENT_PROGRAM_FLOW_ARCS=YES GCC_GENERATE_TEST_COVERAGE_FILES=YES 17 | 18 | 19 | after_success: 20 | - slather -------------------------------------------------------------------------------- /HTMLPurifier-Prefix.gcda: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Mynigma/HTMLPurifier/de1586b6ba4ee38b7855405a85c56f1336a0c481/HTMLPurifier-Prefix.gcda -------------------------------------------------------------------------------- /HTMLPurifier-Prefix.gcno: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Mynigma/HTMLPurifier/de1586b6ba4ee38b7855405a85c56f1336a0c481/HTMLPurifier-Prefix.gcno -------------------------------------------------------------------------------- /HTMLPurifier.podspec: -------------------------------------------------------------------------------- 1 | Pod::Spec.new do |s| 2 | s.name = "HTMLPurifier" 3 | s.version = "1.1.5" 4 | s.summary = "HTMLPurifier for Objective-C is a framework for standards-compliant HTML filtering." 5 | s.description = "HTMLPurifier for Objective-C is a framework for standards-compliant HTML filtering. Its main purpose is sanitisation of untrusted HTML such as incoming emails or user-supplied markup." 6 | s.homepage = "https://mynigma.org" 7 | s.license = { :type => 'GPL with libgit2-style exception' } 8 | s.author = { 'Edward Z. Yang' => 'ezyang@cs.stanford.edu', 9 | 'Roman Priebe' => 'roman@mynigma.org', 10 | 'Lukas Neumann' => 'lukas@mynigma.org' } 11 | s.source = { :git => 'https://github.com/Mynigma/HTMLPurifier.git', :tag => '1.1.5' } 12 | s.social_media_url = 'https://www.facebook.com/mynigma' 13 | 14 | s.ios.deployment_target = '7.0' 15 | s.osx.deployment_target = '10.8' 16 | s.requires_arc = true 17 | 18 | s.source_files = 'HTMLPurifier/**/*.{h,m}' 19 | s.public_header_files = 'HTMLPurifier/**/*.h' 20 | s.resource = 'Supporting Files/HTMLPurifierConfig.plist' 21 | 22 | s.library = 'xml2' 23 | s.xcconfig = { 'HEADER_SEARCH_PATHS' => '$(SDKROOT)/usr/include/libxml2' } 24 | end 25 | -------------------------------------------------------------------------------- /HTMLPurifier.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /HTMLPurifier/Attributes/AttrDef/CSS/HTMLPurifier_AttrDef_CSS.h: -------------------------------------------------------------------------------- 1 | // 2 | // HTMLPurifier_AttrDef_CSS.h 3 | // HTMLPurifier 4 | // 5 | // Created by Lukas Neumann on 13.01.14. 6 | 7 | 8 | 9 | /** 10 | * Validates the HTML attribute style, otherwise known as CSS. 11 | * @note We don't implement the whole CSS specification, so it might be 12 | * difficult to reuse this component in the context of validating 13 | * actual stylesheet declarations. 14 | * @note If we were really serious about validating the CSS, we would 15 | * tokenize the styles and then parse the tokens. Obviously, we 16 | * are not doing that. Doing that could seriously harm performance, 17 | * but would make these components a lot more viable for a CSS 18 | * filtering solution. 19 | */ 20 | 21 | #import "HTMLPurifier_AttrDef.h" 22 | 23 | @interface HTMLPurifier_AttrDef_CSS : HTMLPurifier_AttrDef 24 | 25 | /** 26 | * @param string $css 27 | * @param HTMLPurifier_Config $config 28 | * @param HTMLPurifier_Context $context 29 | * @return bool|string 30 | */ 31 | -(NSString*) validateWithString:(NSString *)css config:(HTMLPurifier_Config *)config context:(HTMLPurifier_Context *)context; 32 | 33 | @end 34 | -------------------------------------------------------------------------------- /HTMLPurifier/Attributes/AttrDef/CSS/HTMLPurifier_AttrDef_CSS_AlphaValue.h: -------------------------------------------------------------------------------- 1 | // 2 | // HTMLPurifier_AttrDef_CSS_AlphaValue.h 3 | // HTMLPurifier 4 | // 5 | // Created by Roman Priebe on 11.01.14. 6 | 7 | 8 | #import "HTMLPurifier_AttrDef_CSS_Number.h" 9 | 10 | @interface HTMLPurifier_AttrDef_CSS_AlphaValue : HTMLPurifier_AttrDef_CSS_Number 11 | 12 | - (NSString*)validateWithString:(NSString *)string config:(HTMLPurifier_Config *)config context:(HTMLPurifier_Context *)context; 13 | 14 | 15 | @end 16 | -------------------------------------------------------------------------------- /HTMLPurifier/Attributes/AttrDef/CSS/HTMLPurifier_AttrDef_CSS_AlphaValue.m: -------------------------------------------------------------------------------- 1 | // 2 | // HTMLPurifier_AttrDef_CSS_AlphaValue.m 3 | // HTMLPurifier 4 | // 5 | // Created by Roman Priebe on 11.01.14. 6 | 7 | 8 | #import "HTMLPurifier_AttrDef_CSS_AlphaValue.h" 9 | 10 | @implementation HTMLPurifier_AttrDef_CSS_AlphaValue 11 | 12 | - (id)init 13 | { 14 | self = [super initWithNonNegative:NO]; // opacity is non-negative, but we will clamp it 15 | 16 | if (self) { 17 | 18 | } 19 | return self; 20 | } 21 | 22 | /** 23 | * @param string $number 24 | * @param HTMLPurifier_Config $config 25 | * @param HTMLPurifier_Context $context 26 | * @return string 27 | */ 28 | - (NSString*)validateWithString:(NSString *)string config:(HTMLPurifier_Config *)config context:(HTMLPurifier_Context *)context 29 | { 30 | NSString* result = [super validateWithString:string config:config context:context]; 31 | if (!result) { 32 | return nil; 33 | } 34 | float floatResult = result.floatValue; 35 | if (floatResult < 0.0) { 36 | result = @"0"; 37 | } 38 | if (floatResult > 1.0) { 39 | result = @"1"; 40 | } 41 | return result; 42 | } 43 | 44 | 45 | @end 46 | -------------------------------------------------------------------------------- /HTMLPurifier/Attributes/AttrDef/CSS/HTMLPurifier_AttrDef_CSS_Background.h: -------------------------------------------------------------------------------- 1 | // 2 | // HTMLPurifier_AttrDef_CSS_Background.h 3 | // HTMLPurifier 4 | // 5 | // Created by Roman Priebe on 11.01.14. 6 | 7 | 8 | #import "HTMLPurifier_AttrDef.h" 9 | 10 | @class HTMLPurifier_Config; 11 | 12 | /** 13 | * Validates shorthand CSS property background. 14 | * @warning Does not support url tokens that have internal spaces. 15 | */ 16 | @interface HTMLPurifier_AttrDef_CSS_Background : HTMLPurifier_AttrDef 17 | { 18 | 19 | /** 20 | * Local copy of component validators. 21 | * @type HTMLPurifier_AttrDef[] 22 | * @note See HTMLPurifier_AttrDef_Font::$info for a similar impl. 23 | */ 24 | NSMutableDictionary* info; 25 | } 26 | /** 27 | * @param HTMLPurifier_Config $config 28 | */ 29 | - (id)initWithConfig:(HTMLPurifier_Config*)config; 30 | 31 | 32 | /** 33 | * @param string $string 34 | * @param HTMLPurifier_Config $config 35 | * @param HTMLPurifier_Context $context 36 | * @return bool|string 37 | */ 38 | - (NSString*)validateWithString:(NSString *)someString config:(HTMLPurifier_Config *)config context:(HTMLPurifier_Context *)context; 39 | 40 | 41 | @end 42 | -------------------------------------------------------------------------------- /HTMLPurifier/Attributes/AttrDef/CSS/HTMLPurifier_AttrDef_CSS_BackgroundPosition.h: -------------------------------------------------------------------------------- 1 | // 2 | // HTMLPurifier_AttrDef_CSS_BackgroundPosition.h 3 | // HTMLPurifier 4 | // 5 | // Created by Roman Priebe on 10.01.14. 6 | 7 | 8 | #import "HTMLPurifier_AttrDef.h" 9 | 10 | @class HTMLPurifier_AttrDef_CSS_Length, HTMLPurifier_AttrDef_CSS_Percentage; 11 | 12 | @interface HTMLPurifier_AttrDef_CSS_BackgroundPosition : HTMLPurifier_AttrDef 13 | { 14 | /** 15 | * @type HTMLPurifier_AttrDef_CSS_Length 16 | */ 17 | HTMLPurifier_AttrDef_CSS_Length* length; 18 | 19 | /** 20 | * @type HTMLPurifier_AttrDef_CSS_Percentage 21 | */ 22 | HTMLPurifier_AttrDef_CSS_Percentage* percentage; 23 | } 24 | 25 | 26 | /** 27 | * @param string $string 28 | * @param HTMLPurifier_Config $config 29 | * @param HTMLPurifier_Context $context 30 | * @return bool|string 31 | */ 32 | - (NSString*)validateWithString:(NSString *)string config:(HTMLPurifier_Config *)config context:(HTMLPurifier_Context *)context; 33 | 34 | 35 | 36 | @end 37 | -------------------------------------------------------------------------------- /HTMLPurifier/Attributes/AttrDef/CSS/HTMLPurifier_AttrDef_CSS_Border.h: -------------------------------------------------------------------------------- 1 | // 2 | // HTMLPurifier_AttrDef_CSS_Border.h 3 | // HTMLPurifier 4 | // 5 | // Created by Roman Priebe on 11.01.14. 6 | 7 | 8 | #import "HTMLPurifier_AttrDef.h" 9 | 10 | @interface HTMLPurifier_AttrDef_CSS_Border : HTMLPurifier_AttrDef 11 | /** 12 | * Validates the border property as defined by CSS. 13 | */ 14 | { 15 | 16 | /** 17 | * Local copy of properties this property is shorthand for. 18 | * @type HTMLPurifier_AttrDef[] 19 | */ 20 | NSMutableDictionary* info; 21 | } 22 | 23 | 24 | - (id)initWithConfig:(HTMLPurifier_Config*)config; 25 | 26 | - (NSString*)validateWithString:(NSString*)string config:(HTMLPurifier_Config*)config context:(HTMLPurifier_Context*)context; 27 | 28 | @end 29 | -------------------------------------------------------------------------------- /HTMLPurifier/Attributes/AttrDef/CSS/HTMLPurifier_AttrDef_CSS_BorderRadius.h: -------------------------------------------------------------------------------- 1 | // 2 | // HTMLPurifier_AttrDef_CSS_BorderRadius.h 3 | // HTMLPurifier 4 | // 5 | // Created by Lukas Neumann on 15.08.15. 6 | // Copyright (c) 2015 Mynigma. All rights reserved. 7 | // 8 | 9 | #import "HTMLPurifier_AttrDef.h" 10 | 11 | @interface HTMLPurifier_AttrDef_CSS_BorderRadius : HTMLPurifier_AttrDef 12 | /** 13 | * Validates the border-radius property as defined by CSS. 14 | */ 15 | 16 | - (NSString*)validateWithString:(NSString*)string config:(HTMLPurifier_Config*)config context:(HTMLPurifier_Context*)context; 17 | 18 | @end 19 | 20 | -------------------------------------------------------------------------------- /HTMLPurifier/Attributes/AttrDef/CSS/HTMLPurifier_AttrDef_CSS_Color.h: -------------------------------------------------------------------------------- 1 | // 2 | // HTMLPurifier_AttrDef_CSS_Color.h 3 | // HTMLPurifier 4 | // 5 | // Created by Roman Priebe on 11.01.14. 6 | 7 | 8 | #import "HTMLPurifier_AttrDef.h" 9 | 10 | /** 11 | * Validates Color as defined by CSS. 12 | */ 13 | @interface HTMLPurifier_AttrDef_CSS_Color : HTMLPurifier_AttrDef 14 | 15 | 16 | /** 17 | * @param string $color 18 | * @param HTMLPurifier_Config $config 19 | * @param HTMLPurifier_Context $context 20 | * @return bool|string 21 | */ 22 | - (NSString*)validateWithString:(NSString *)string config:(HTMLPurifier_Config *)config context:(HTMLPurifier_Context *)context; 23 | 24 | 25 | @end 26 | -------------------------------------------------------------------------------- /HTMLPurifier/Attributes/AttrDef/CSS/HTMLPurifier_AttrDef_CSS_Composite.h: -------------------------------------------------------------------------------- 1 | // 2 | // HTMLPurifier_AttrDef_CSS_Composite.h 3 | // HTMLPurifier 4 | // 5 | // Created by Roman Priebe on 10.01.14. 6 | 7 | 8 | #import "HTMLPurifier_AttrDef.h" 9 | 10 | @interface HTMLPurifier_AttrDef_CSS_Composite : HTMLPurifier_AttrDef 11 | 12 | 13 | /** 14 | * List of objects that may process strings. 15 | * @type HTMLPurifier_AttrDef[] 16 | * @todo Make protected 17 | */ 18 | @property NSMutableArray* defs; 19 | 20 | - (id)initWithDefs:(NSArray*)newDefs; 21 | 22 | 23 | @end 24 | -------------------------------------------------------------------------------- /HTMLPurifier/Attributes/AttrDef/CSS/HTMLPurifier_AttrDef_CSS_Composite.m: -------------------------------------------------------------------------------- 1 | // 2 | // HTMLPurifier_AttrDef_CSS_Composite.m 3 | // HTMLPurifier 4 | // 5 | // Created by Roman Priebe on 10.01.14. 6 | 7 | 8 | #import "HTMLPurifier_AttrDef_CSS_Composite.h" 9 | 10 | @implementation HTMLPurifier_AttrDef_CSS_Composite 11 | 12 | - (id)initWithDefs:(NSArray*)newDefs 13 | { 14 | self = [super init]; 15 | if (self) { 16 | _defs = [newDefs mutableCopy]; 17 | } 18 | return self; 19 | } 20 | /** 21 | * @param string $string 22 | * @param HTMLPurifier_Config $config 23 | * @param HTMLPurifier_Context $context 24 | * @return bool|string 25 | */ 26 | - (NSString*)validateWithString:(NSString *)string config:(HTMLPurifier_Config *)config context:(HTMLPurifier_Context *)context 27 | { 28 | for(HTMLPurifier_AttrDef* def in self.defs) 29 | { 30 | NSString* result = [def validateWithString:string config:config context:context]; 31 | if(result) 32 | return result; 33 | } 34 | return nil; 35 | } 36 | 37 | @end 38 | -------------------------------------------------------------------------------- /HTMLPurifier/Attributes/AttrDef/CSS/HTMLPurifier_AttrDef_CSS_DenyElementDecorator.h: -------------------------------------------------------------------------------- 1 | // 2 | // HTMLPurifier_AttrDef_CSS_DenyElementDecorator.h 3 | // HTMLPurifier 4 | // 5 | // Created by Lukas Neumann on 15.01.14. 6 | 7 | 8 | 9 | /** 10 | * Decorator which enables CSS properties to be disabled for specific elements. 11 | */ 12 | 13 | #import "HTMLPurifier_AttrDef.h" 14 | 15 | @interface HTMLPurifier_AttrDef_CSS_DenyElementDecorator : HTMLPurifier_AttrDef 16 | 17 | /** 18 | * @type HTMLPurifier_AttrDef 19 | */ 20 | @property HTMLPurifier_AttrDef* def; 21 | 22 | /** 23 | * @type string 24 | */ 25 | @property NSString* element; 26 | 27 | 28 | /** 29 | * @param HTMLPurifier_AttrDef def Definition to wrap 30 | * @param string element Element to deny 31 | */ 32 | -(id) initWithDef:(HTMLPurifier_AttrDef*)ndef Element:(NSString*) nelement; 33 | 34 | /** 35 | * Checks if CurrentToken is set and equal to this->element 36 | * @param string string 37 | * @param HTMLPurifier_Config config 38 | * @param HTMLPurifier_Context context 39 | * @return bool|string 40 | */ 41 | -(NSString*) validateWithString:(NSString *)string config:(HTMLPurifier_Config *)config context:(HTMLPurifier_Context *)context; 42 | 43 | @end 44 | -------------------------------------------------------------------------------- /HTMLPurifier/Attributes/AttrDef/CSS/HTMLPurifier_AttrDef_CSS_Filter.h: -------------------------------------------------------------------------------- 1 | // 2 | // HTMLPurifier_AttrDef_CSS_Filter.h 3 | // HTMLPurifier 4 | // 5 | // Created by Lukas Neumann on 15.01.14. 6 | 7 | 8 | #import "HTMLPurifier_AttrDef.h" 9 | #import "HTMLPurifier_AttrDef_Integer.h" 10 | 11 | /** 12 | * Microsoft's proprietary filter: CSS property 13 | * @note Currently supports the alpha filter. In the future, this will 14 | * probably need an extensible framework 15 | */ 16 | 17 | @interface HTMLPurifier_AttrDef_CSS_Filter : HTMLPurifier_AttrDef 18 | 19 | /** 20 | * @type HTMLPurifier_AttrDef_Integer 21 | */ 22 | @property HTMLPurifier_AttrDef_Integer* intValidator; 23 | 24 | -(id) init; 25 | 26 | @end 27 | -------------------------------------------------------------------------------- /HTMLPurifier/Attributes/AttrDef/CSS/HTMLPurifier_AttrDef_CSS_Font.h: -------------------------------------------------------------------------------- 1 | // 2 | // HTMLPurifier_AttrDef_CSS_Font.h 3 | // HTMLPurifier 4 | // 5 | // Created by Roman Priebe on 14.01.14. 6 | 7 | 8 | #import "HTMLPurifier_AttrDef.h" 9 | 10 | /** 11 | * Validates shorthand CSS property font. 12 | */ 13 | @interface HTMLPurifier_AttrDef_CSS_Font : HTMLPurifier_AttrDef 14 | { 15 | /** 16 | * Local copy of validators 17 | * @type HTMLPurifier_AttrDef[] 18 | * @note If we moved specific CSS property definitions to their own 19 | * classes instead of having them be assembled at run time by 20 | * CSSDefinition, this wouldn't be necessary. We'd instantiate 21 | * our own copies. 22 | */ 23 | NSMutableDictionary* info; 24 | } /** 25 | * @param HTMLPurifier_Config $config 26 | */ 27 | - (id)initWithConfig:(HTMLPurifier_Config*)config; 28 | 29 | /** 30 | * @param string $string 31 | * @param HTMLPurifier_Config $config 32 | * @param HTMLPurifier_Context $context 33 | * @return bool|string 34 | */ 35 | - (NSString*)validateWithString:(NSString *)theString config:(HTMLPurifier_Config *)config context:(HTMLPurifier_Context *)context; 36 | 37 | 38 | @end 39 | -------------------------------------------------------------------------------- /HTMLPurifier/Attributes/AttrDef/CSS/HTMLPurifier_AttrDef_CSS_FontFamily.h: -------------------------------------------------------------------------------- 1 | // 2 | // HTMLPurifier_AttrDef_CSS_FontFamily.h 3 | // HTMLPurifier 4 | // 5 | // Created by Roman Priebe on 14.01.14. 6 | 7 | 8 | #import "HTMLPurifier_AttrDef.h" 9 | 10 | @class HTMLPurifier_Context, HTMLPurifier_Config; 11 | 12 | /** 13 | * Validates a font family list according to CSS spec 14 | */ 15 | @interface HTMLPurifier_AttrDef_CSS_FontFamily : HTMLPurifier_AttrDef 16 | { 17 | NSMutableString* mask; 18 | } 19 | 20 | - (NSString*)validateWithString:(NSString*)string config:(HTMLPurifier_Config*)config context:(HTMLPurifier_Context*)context; 21 | 22 | 23 | 24 | @end 25 | -------------------------------------------------------------------------------- /HTMLPurifier/Attributes/AttrDef/CSS/HTMLPurifier_AttrDef_CSS_Ident.h: -------------------------------------------------------------------------------- 1 | // 2 | // HTMLPurifier_AttrDef_CSS_Ident.h 3 | // HTMLPurifier 4 | // 5 | // Created by Lukas Neumann on 15.01.14. 6 | 7 | 8 | /** 9 | * Validates based on {ident} CSS grammar production 10 | */ 11 | 12 | #import "HTMLPurifier_AttrDef.h" 13 | 14 | @interface HTMLPurifier_AttrDef_CSS_Ident : HTMLPurifier_AttrDef 15 | 16 | /** 17 | * @param string $string 18 | * @param HTMLPurifier_Config $config 19 | * @param HTMLPurifier_Context $context 20 | * @return bool|string 21 | */ 22 | -(NSString*) validateWithString:(NSString *)string config:(HTMLPurifier_Config *)config context:(HTMLPurifier_Context *)context; 23 | 24 | @end 25 | -------------------------------------------------------------------------------- /HTMLPurifier/Attributes/AttrDef/CSS/HTMLPurifier_AttrDef_CSS_Ident.m: -------------------------------------------------------------------------------- 1 | // 2 | // HTMLPurifier_AttrDef_CSS_Ident.m 3 | // HTMLPurifier 4 | // 5 | // Created by Lukas Neumann on 15.01.14. 6 | 7 | 8 | 9 | /** 10 | * Validates based on {ident} CSS grammar production 11 | */ 12 | 13 | #import "HTMLPurifier_AttrDef_CSS_Ident.h" 14 | #import "BasicPHP.h" 15 | 16 | @implementation HTMLPurifier_AttrDef_CSS_Ident 17 | 18 | 19 | /** 20 | * @param string $string 21 | * @param HTMLPurifier_Config $config 22 | * @param HTMLPurifier_Context $context 23 | * @return bool|string 24 | */ 25 | -(NSString*) validateWithString:(NSString *)string config:(HTMLPurifier_Config *)config context:(HTMLPurifier_Context *)context 26 | { 27 | string = trim(string); 28 | 29 | // early abort: '' and '0' (strings that convert to false) are invalid 30 | if ([string isEqual:@""] || [string isEqual:@"0"]) { 31 | return nil; 32 | } 33 | 34 | NSString* pattern = @"^(-?[A-Za-z_][A-Za-z_\\-0-9]*)$"; 35 | if (!preg_match_2(pattern, string)) { 36 | return nil; 37 | } 38 | return string; 39 | } 40 | 41 | @end 42 | -------------------------------------------------------------------------------- /HTMLPurifier/Attributes/AttrDef/CSS/HTMLPurifier_AttrDef_CSS_ImportantDecorator.h: -------------------------------------------------------------------------------- 1 | // 2 | // HTMLPurifier_AttrDef_CSS_ImportantDecorator.h 3 | // HTMLPurifier 4 | // 5 | // Created by Lukas Neumann on 15.01.14. 6 | 7 | 8 | /** 9 | * Decorator which enables !important to be used in CSS values. 10 | */ 11 | 12 | #import "HTMLPurifier_AttrDef.h" 13 | 14 | @interface HTMLPurifier_AttrDef_CSS_ImportantDecorator : HTMLPurifier_AttrDef 15 | 16 | /** 17 | * @type HTMLPurifier_AttrDef 18 | */ 19 | @property HTMLPurifier_AttrDef* def; 20 | 21 | /** 22 | * @type bool 23 | */ 24 | @property NSNumber* allow; 25 | 26 | 27 | /** 28 | * @param HTMLPurifier_AttrDef $def Definition to wrap 29 | * @param bool $allow Whether or not to allow !important 30 | */ 31 | -(id) initWithDef:(HTMLPurifier_AttrDef*)ndef AllowImportant:(NSNumber*)nallow; 32 | 33 | /** 34 | * Intercepts and removes !important if necessary 35 | * @param string $string 36 | * @param HTMLPurifier_Config $config 37 | * @param HTMLPurifier_Context $context 38 | * @return bool|string 39 | */ 40 | -(NSString*) validateWithString:(NSString *)string config:(HTMLPurifier_Config *)config context:(HTMLPurifier_Context *)context; 41 | 42 | @end 43 | -------------------------------------------------------------------------------- /HTMLPurifier/Attributes/AttrDef/CSS/HTMLPurifier_AttrDef_CSS_Length.h: -------------------------------------------------------------------------------- 1 | // 2 | // HTMLPurifier_AttrDef_CSS_Length.h 3 | // HTMLPurifier 4 | // 5 | // Created by Roman Priebe on 11.01.14. 6 | 7 | 8 | #import "HTMLPurifier_AttrDef.h" 9 | 10 | @class HTMLPurifier_Length; 11 | 12 | @interface HTMLPurifier_AttrDef_CSS_Length : HTMLPurifier_AttrDef 13 | { 14 | 15 | /** 16 | * @type HTMLPurifier_Length|string 17 | */ 18 | HTMLPurifier_Length* min; 19 | 20 | /** 21 | * @type HTMLPurifier_Length|string 22 | */ 23 | HTMLPurifier_Length* max; 24 | } 25 | 26 | - (id)initWithMin:(NSObject*)newMin max:(NSObject*)newMax; 27 | - (id)initWithMin:(NSObject*)newMin; 28 | - (id)init; 29 | 30 | - (NSString*)validateWithString:(NSString *)string config:(HTMLPurifier_Config *)config context:(HTMLPurifier_Context *)context; 31 | 32 | 33 | 34 | @end 35 | -------------------------------------------------------------------------------- /HTMLPurifier/Attributes/AttrDef/CSS/HTMLPurifier_AttrDef_CSS_ListStyle.h: -------------------------------------------------------------------------------- 1 | // 2 | // HTMLPurifier_AttrDef_CSS_ListStyle.h 3 | // HTMLPurifier 4 | // 5 | // Created by Roman Priebe on 11.01.14. 6 | 7 | 8 | #import "HTMLPurifier_AttrDef.h" 9 | 10 | /** 11 | * Validates shorthand CSS property list-style. 12 | * @warning Does not support url tokens that have internal spaces. 13 | */ 14 | 15 | @interface HTMLPurifier_AttrDef_CSS_ListStyle : HTMLPurifier_AttrDef 16 | { 17 | /** 18 | * Local copy of validators. 19 | * @type HTMLPurifier_AttrDef[] 20 | * @note See HTMLPurifier_AttrDef_CSS_Font::$info for a similar impl. 21 | */ 22 | NSMutableDictionary* info; 23 | } 24 | 25 | 26 | - (id)initWithConfig:(HTMLPurifier_Config*)config; 27 | 28 | - (NSString*)validateWithString:(NSString *)string config:(HTMLPurifier_Config *)config context:(HTMLPurifier_Context *)context; 29 | 30 | 31 | @end 32 | -------------------------------------------------------------------------------- /HTMLPurifier/Attributes/AttrDef/CSS/HTMLPurifier_AttrDef_CSS_Multiple.h: -------------------------------------------------------------------------------- 1 | // 2 | // HTMLPurifier_AttrDef_CSS_Multiple.h 3 | // HTMLPurifier 4 | // 5 | // Created by Roman Priebe on 10.01.14. 6 | 7 | 8 | #import "HTMLPurifier_AttrDef.h" 9 | 10 | @interface HTMLPurifier_AttrDef_CSS_Multiple : HTMLPurifier_AttrDef 11 | 12 | @property HTMLPurifier_AttrDef* single; 13 | 14 | @property NSInteger max; 15 | 16 | - (id)initWithSingle:(HTMLPurifier_AttrDef*)single max:(NSInteger)max; 17 | - (id)initWithSingle:(HTMLPurifier_AttrDef*)single; 18 | 19 | - (NSString*)validateWithString:(NSString*)string config:(HTMLPurifier_Config*)config context:(HTMLPurifier_Context*)context; 20 | 21 | 22 | @end 23 | -------------------------------------------------------------------------------- /HTMLPurifier/Attributes/AttrDef/CSS/HTMLPurifier_AttrDef_CSS_Number.h: -------------------------------------------------------------------------------- 1 | // 2 | // HTMLPurifier_AttrDef_Number.h 3 | // HTMLPurifier 4 | // 5 | // Created by Roman Priebe on 11.01.14. 6 | 7 | 8 | #import "HTMLPurifier_AttrDef.h" 9 | 10 | @class HTMLPurifier_Config, HTMLPurifier_Context; 11 | 12 | /** 13 | * Validates a number as defined by the CSS spec. 14 | */ 15 | @interface HTMLPurifier_AttrDef_CSS_Number : HTMLPurifier_AttrDef 16 | { 17 | /** 18 | * Indicates whether or not only positive values are allowed. 19 | * @type bool 20 | */ 21 | BOOL nonNegative; 22 | } 23 | 24 | - (id)initWithNonNegative:(BOOL)newNonNegative; 25 | 26 | 27 | - (NSString*)validateWithString:(NSString *)string config:(HTMLPurifier_Config *)config context:(HTMLPurifier_Context *)context; 28 | 29 | 30 | @end 31 | -------------------------------------------------------------------------------- /HTMLPurifier/Attributes/AttrDef/CSS/HTMLPurifier_AttrDef_CSS_Outline.h: -------------------------------------------------------------------------------- 1 | // 2 | // HTMLPurifier_AttrDef_CSS_Outline.h 3 | // HTMLPurifier 4 | // 5 | // Created by Lukas Neumann on 15.08.15. 6 | // Copyright (c) 2015 Mynigma. All rights reserved. 7 | // 8 | 9 | #import "HTMLPurifier_AttrDef.h" 10 | 11 | @interface HTMLPurifier_AttrDef_CSS_Outline : HTMLPurifier_AttrDef 12 | 13 | /** 14 | * Validates the outline property as defined by CSS. 15 | */ 16 | { 17 | /** 18 | * Local copy of properties this property is shorthand for. 19 | * @type HTMLPurifier_AttrDef[] 20 | */ 21 | NSMutableDictionary* info; 22 | } 23 | 24 | 25 | - (id)initWithConfig:(HTMLPurifier_Config*)config; 26 | 27 | - (NSString*)validateWithString:(NSString*)string config:(HTMLPurifier_Config*)config context:(HTMLPurifier_Context*)context; 28 | 29 | @end 30 | -------------------------------------------------------------------------------- /HTMLPurifier/Attributes/AttrDef/CSS/HTMLPurifier_AttrDef_CSS_Percentage.h: -------------------------------------------------------------------------------- 1 | // 2 | // HTMLPurifier_AttrDef_Percentage.h 3 | // HTMLPurifier 4 | // 5 | // Created by Roman Priebe on 11.01.14. 6 | 7 | 8 | #import "HTMLPurifier_AttrDef.h" 9 | 10 | @class HTMLPurifier_AttrDef_CSS_Number, HTMLPurifier_Config, HTMLPurifier_Context; 11 | 12 | @interface HTMLPurifier_AttrDef_CSS_Percentage : HTMLPurifier_AttrDef 13 | { 14 | /** 15 | * Instance to defer number validation to. 16 | * @type HTMLPurifier_AttrDef_CSS_Number 17 | */ 18 | HTMLPurifier_AttrDef_CSS_Number* numberDef; 19 | } 20 | 21 | - (id)initWithNonNegative:(BOOL)nonNegative; 22 | 23 | /** 24 | * @param string $string 25 | * @param HTMLPurifier_Config $config 26 | * @param HTMLPurifier_Context $context 27 | * @return bool|string 28 | */ 29 | - (NSString*)validateWithString:(NSString*)string config:(HTMLPurifier_Config*)config context:(HTMLPurifier_Context*)context; 30 | 31 | 32 | @end 33 | -------------------------------------------------------------------------------- /HTMLPurifier/Attributes/AttrDef/CSS/HTMLPurifier_AttrDef_CSS_Shape.h: -------------------------------------------------------------------------------- 1 | // 2 | // HTMLPurifier_AttrDef_CSS_Shape 3 | // HTMLPurifier 4 | // 5 | // Created by Lukas Neumann on 13.08.15. 6 | // Copyright (c) 2015 Mynigma. All rights reserved. 7 | // 8 | 9 | #import "HTMLPurifier_AttrDef.h" 10 | 11 | @interface HTMLPurifier_AttrDef_CSS_Shape : HTMLPurifier_AttrDef 12 | /** 13 | * Validates the shape property as defined by CSS. 14 | */ 15 | 16 | - (NSString*)validateWithString:(NSString*)string config:(HTMLPurifier_Config*)config context:(HTMLPurifier_Context*)context; 17 | 18 | @end 19 | -------------------------------------------------------------------------------- /HTMLPurifier/Attributes/AttrDef/CSS/HTMLPurifier_AttrDef_CSS_TextDecoration.h: -------------------------------------------------------------------------------- 1 | // 2 | // HTMLPurifier_AttrDef_CSS_TextDecoration.h 3 | // HTMLPurifier 4 | // 5 | // Created by Roman Priebe on 11.01.14. 6 | 7 | 8 | #import "HTMLPurifier_AttrDef.h" 9 | 10 | @interface HTMLPurifier_AttrDef_CSS_TextDecoration : HTMLPurifier_AttrDef 11 | 12 | /** 13 | * @param string $string 14 | * @param HTMLPurifier_Config $config 15 | * @param HTMLPurifier_Context $context 16 | * @return bool|string 17 | */ 18 | - (NSString*)validateWithString:(NSString *)string config:(HTMLPurifier_Config *)config context:(HTMLPurifier_Context *)context; 19 | 20 | @end 21 | -------------------------------------------------------------------------------- /HTMLPurifier/Attributes/AttrDef/CSS/HTMLPurifier_AttrDef_CSS_TextDecoration.m: -------------------------------------------------------------------------------- 1 | // 2 | // HTMLPurifier_AttrDef_CSS_TextDecoration.m 3 | // HTMLPurifier 4 | // 5 | // Created by Roman Priebe on 11.01.14. 6 | 7 | 8 | #import "HTMLPurifier_AttrDef_CSS_TextDecoration.h" 9 | #import "BasicPHP.h" 10 | 11 | @implementation HTMLPurifier_AttrDef_CSS_TextDecoration 12 | 13 | /** 14 | * @param string $string 15 | * @param HTMLPurifier_Config $config 16 | * @param HTMLPurifier_Context $context 17 | * @return bool|string 18 | */ 19 | - (NSString*)validateWithString:(NSString *)string config:(HTMLPurifier_Config *)config context:(HTMLPurifier_Context *)context 20 | { 21 | NSDictionary* allowedValues = @{@"line-through":@YES, @"overline":@YES, @"underline":@YES}; 22 | 23 | string = [[self parseCDATAWithString:string] lowercaseString]; 24 | 25 | if ([string isEqual:@"none"]) 26 | { 27 | return string; 28 | } 29 | 30 | NSArray* parts = explode(@" ", string); 31 | NSMutableString* final = [@"" mutableCopy]; 32 | for(NSString* part in parts) 33 | { 34 | if([allowedValues objectForKey:part]) 35 | { 36 | [final appendFormat:@"%@ ", part]; 37 | } 38 | } 39 | final = [trim(final) mutableCopy]; 40 | if ([final isEqual:@""]) 41 | { 42 | return nil; 43 | } 44 | return final; 45 | } 46 | 47 | @end 48 | -------------------------------------------------------------------------------- /HTMLPurifier/Attributes/AttrDef/CSS/HTMLPurifier_AttrDef_CSS_URI.h: -------------------------------------------------------------------------------- 1 | // 2 | // HTMLPurifier_AttrDef_CSS_URI.h 3 | // HTMLPurifier 4 | // 5 | // Created by Roman Priebe on 11.01.14. 6 | 7 | 8 | #import "HTMLPurifier_AttrDef_URI.h" 9 | 10 | @interface HTMLPurifier_AttrDef_CSS_URI : HTMLPurifier_AttrDef_URI 11 | 12 | /* 13 | public function __construct() 14 | { 15 | parent::__construct(true); // always embedded 16 | }*/ 17 | 18 | /** 19 | * @param string $uri_string 20 | * @param HTMLPurifier_Config $config 21 | * @param HTMLPurifier_Context $context 22 | * @return bool|string 23 | */ 24 | - (NSString*)validateWithString:(NSString *)string config:(HTMLPurifier_Config *)config context:(HTMLPurifier_Context *)context; 25 | 26 | @end 27 | -------------------------------------------------------------------------------- /HTMLPurifier/Attributes/AttrDef/HTML/HTMLPurifier_AttrDef_HTML_Bool.h: -------------------------------------------------------------------------------- 1 | // 2 | // HTMLPurifier_AttrDef_HTML_Bool.h 3 | // HTMLPurifier 4 | // 5 | // Created by Lukas Neumann on 10.01.14. 6 | 7 | 8 | #import 9 | 10 | #import "HTMLPurifier_AttrDef.h" 11 | 12 | /** 13 | * Validates a boolean attribute 14 | */ 15 | @interface HTMLPurifier_AttrDef_HTML_Bool :HTMLPurifier_AttrDef 16 | 17 | @property NSString* name; 18 | 19 | @property BOOL minimized; 20 | 21 | 22 | -(id)initWithName:(NSString*)newName; 23 | 24 | /** 25 | * @param string $string 26 | * @param HTMLPurifier_Config $config 27 | * @param HTMLPurifier_Context $context 28 | * @return bool|string 29 | */ 30 | 31 | -(NSString*) validateWithString:(NSString*)string config:(HTMLPurifier_Config*)config context:(HTMLPurifier_Context*)context; 32 | 33 | /** 34 | * @param string $string Name of attribute 35 | * @return HTMLPurifier_AttrDef_HTML_Bool 36 | */ 37 | -(HTMLPurifier_AttrDef_HTML_Bool*) make:(NSString*)string; 38 | 39 | 40 | @end 41 | -------------------------------------------------------------------------------- /HTMLPurifier/Attributes/AttrDef/HTML/HTMLPurifier_AttrDef_HTML_Class.h: -------------------------------------------------------------------------------- 1 | // 2 | // HTMLPurifier_AttrDef_HTML_Class.h 3 | // HTMLPurifier 4 | // 5 | // Created by Lukas Neumann on 10.01.14. 6 | 7 | 8 | #import "HTMLPurifier_AttrDef_HTML_Nmtokens.h" 9 | 10 | /** 11 | * Implements special behavior for class attribute (normally NMTOKENS) 12 | */ 13 | @interface HTMLPurifier_AttrDef_HTML_Class : HTMLPurifier_AttrDef_HTML_Nmtokens 14 | 15 | /** 16 | * @param string $string 17 | * @param HTMLPurifier_Config $config 18 | * @param HTMLPurifier_Context $context 19 | * @return bool|string 20 | */ 21 | -(NSString*) splitWithString:(NSString*)string config:(HTMLPurifier_Config*)config context:(HTMLPurifier_Context*)context; 22 | 23 | /** 24 | * @param array $tokens 25 | * @param HTMLPurifier_Config $config 26 | * @param HTMLPurifier_Context $context 27 | * @return array 28 | */ 29 | -(NSMutableArray*) filterWithTokens:(NSMutableArray*)tokens config:(HTMLPurifier_Config*)config context:(HTMLPurifier_Context*)context; 30 | 31 | @end 32 | -------------------------------------------------------------------------------- /HTMLPurifier/Attributes/AttrDef/HTML/HTMLPurifier_AttrDef_HTML_Color.h: -------------------------------------------------------------------------------- 1 | // 2 | // HTMLPurifier_AttrDef_HTML_Color.h 3 | // HTMLPurifier 4 | // 5 | // Created by Lukas Neumann on 11.01.14. 6 | 7 | 8 | #import "HTMLPurifier_AttrDef.h" 9 | 10 | @interface HTMLPurifier_AttrDef_HTML_Color : HTMLPurifier_AttrDef 11 | 12 | /** 13 | * @param string $string 14 | * @param HTMLPurifier_Config $config 15 | * @param HTMLPurifier_Context $context 16 | * @return bool|string 17 | */ 18 | 19 | -(NSString*)validateWithString:string config:(HTMLPurifier_Config *)config context:(HTMLPurifier_Context *)context; 20 | 21 | @end 22 | -------------------------------------------------------------------------------- /HTMLPurifier/Attributes/AttrDef/HTML/HTMLPurifier_AttrDef_HTML_FrameTarget.h: -------------------------------------------------------------------------------- 1 | // 2 | // HTMLPurifier_AttrDef_HTML_FrameTarget.h 3 | // HTMLPurifier 4 | // 5 | // Created by Lukas Neumann on 11.01.14. 6 | 7 | 8 | #import "HTMLPurifier_AttrDef_Enum.h" 9 | 10 | @interface HTMLPurifier_AttrDef_HTML_FrameTarget : HTMLPurifier_AttrDef_Enum 11 | 12 | @property BOOL case_sensitive; 13 | 14 | /** 15 | * @param string $string 16 | * @param HTMLPurifier_Config $config 17 | * @param HTMLPurifier_Context $context 18 | * @return bool|string 19 | */ 20 | -(NSString*) validateWithString:(NSString *)string config:(HTMLPurifier_Config *)config context:(HTMLPurifier_Context *)context; 21 | 22 | @end 23 | -------------------------------------------------------------------------------- /HTMLPurifier/Attributes/AttrDef/HTML/HTMLPurifier_AttrDef_HTML_FrameTarget.m: -------------------------------------------------------------------------------- 1 | // 2 | // HTMLPurifier_AttrDef_HTML_FrameTarget.m 3 | // HTMLPurifier 4 | // 5 | // Created by Lukas Neumann on 11.01.14. 6 | 7 | 8 | #import "HTMLPurifier_AttrDef_HTML_FrameTarget.h" 9 | 10 | @implementation HTMLPurifier_AttrDef_HTML_FrameTarget 11 | 12 | /** 13 | * @type array 14 | */ 15 | 16 | /** 17 | * @type bool 18 | */ 19 | 20 | -(id) init 21 | { 22 | self = [super init]; 23 | return self; 24 | } 25 | 26 | /** 27 | * @param string $string 28 | * @param HTMLPurifier_Config $config 29 | * @param HTMLPurifier_Context $context 30 | * @return bool|string 31 | */ 32 | -(NSString*) validateWithString:(NSString *)string config:(HTMLPurifier_Config *)config context:(HTMLPurifier_Context *)context 33 | { 34 | if (!self.validValues) 35 | { 36 | NSObject* allowedFrameTargets = [(NSMutableDictionary*)[config get:@"Attr.AllowedFrameTargets"] mutableCopy]; 37 | if(![allowedFrameTargets isKindOfClass:[NSArray class]]) 38 | allowedFrameTargets = [NSMutableArray new]; 39 | [self setValidValues:(NSMutableArray*)allowedFrameTargets]; 40 | } 41 | return [super validateWithString:string config:config context:context]; 42 | } 43 | 44 | @end 45 | -------------------------------------------------------------------------------- /HTMLPurifier/Attributes/AttrDef/HTML/HTMLPurifier_AttrDef_HTML_ID.h: -------------------------------------------------------------------------------- 1 | // 2 | // HTMLPurifier_AttrDef_HTML_ID.h 3 | // HTMLPurifier 4 | // 5 | // Created by Lukas Neumann on 11.01.14. 6 | 7 | 8 | #import "HTMLPurifier_AttrDef.h" 9 | 10 | /** 11 | * Validates the HTML attribute ID. 12 | * @warning Even though this is the id processor, it 13 | * will ignore the directive Attr:IDBlacklist, since it will only 14 | * go according to the ID accumulator. Since the accumulator is 15 | * automatically generated, it will have already absorbed the 16 | * blacklist. If you're hacking around, make sure you use load()! 17 | */ 18 | 19 | @interface HTMLPurifier_AttrDef_HTML_ID : HTMLPurifier_AttrDef 20 | 21 | /** 22 | * Determines whether or not we're validating an ID in a CSS 23 | * selector context. 24 | * @type bool 25 | */ 26 | @property NSNumber* selector; 27 | 28 | /** 29 | * @param string $id 30 | * @param HTMLPurifier_Config $config 31 | * @param HTMLPurifier_Context $context 32 | * @return bool|string 33 | */ 34 | -(NSString*) validateWithString:(NSString*)ID config:(HTMLPurifier_Config*)config context:(HTMLPurifier_Context*)context; 35 | 36 | @end 37 | -------------------------------------------------------------------------------- /HTMLPurifier/Attributes/AttrDef/HTML/HTMLPurifier_AttrDef_HTML_Length.h: -------------------------------------------------------------------------------- 1 | // 2 | // HTMLPurifier_AttrDef_HTML_Length.h 3 | // HTMLPurifier 4 | // 5 | // Created by Lukas Neumann on 12.01.14. 6 | 7 | 8 | #import "HTMLPurifier_AttrDef_HTML_Pixels.h" 9 | 10 | @interface HTMLPurifier_AttrDef_HTML_Length : HTMLPurifier_AttrDef_HTML_Pixels 11 | 12 | /** 13 | * @param string $string 14 | * @param HTMLPurifier_Config $config 15 | * @param HTMLPurifier_Context $context 16 | * @return bool|string 17 | */ 18 | - (NSString*)validateWithString:(NSString *)string config:(HTMLPurifier_Config *)config context:(HTMLPurifier_Context *)context; 19 | 20 | @end 21 | -------------------------------------------------------------------------------- /HTMLPurifier/Attributes/AttrDef/HTML/HTMLPurifier_AttrDef_HTML_LinkTypes.h: -------------------------------------------------------------------------------- 1 | // 2 | // HTMLPurifier_AttrDef_HTML_LinkTypes.h 3 | // HTMLPurifier 4 | // 5 | // Created by Lukas Neumann on 12.01.14. 6 | 7 | 8 | #import "HTMLPurifier_AttrDef.h" 9 | 10 | @interface HTMLPurifier_AttrDef_HTML_LinkTypes : HTMLPurifier_AttrDef 11 | 12 | /** 13 | * Name config attribute to pull. 14 | * @type string 15 | */ 16 | @property NSString* name; 17 | 18 | /** 19 | * @param string newName 20 | */ 21 | -(id) initWithName:(NSString*)newName; 22 | 23 | @end 24 | -------------------------------------------------------------------------------- /HTMLPurifier/Attributes/AttrDef/HTML/HTMLPurifier_AttrDef_HTML_MultiLength.h: -------------------------------------------------------------------------------- 1 | // 2 | // HTMLPurifier_AttrDef_HTML_MultiLength.h 3 | // HTMLPurifier 4 | // 5 | // Created by Lukas Neumann on 12.01.14. 6 | 7 | 8 | #import "HTMLPurifier_AttrDef_HTML_Length.h" 9 | 10 | @interface HTMLPurifier_AttrDef_HTML_MultiLength : HTMLPurifier_AttrDef_HTML_Length 11 | 12 | /** 13 | * @param string $string 14 | * @param HTMLPurifier_Config $config 15 | * @param HTMLPurifier_Context $context 16 | * @return bool|string 17 | */ 18 | -(NSString*) validateWithString:(NSString *)string config:(HTMLPurifier_Config *)config context:(HTMLPurifier_Context *)context; 19 | 20 | @end 21 | -------------------------------------------------------------------------------- /HTMLPurifier/Attributes/AttrDef/HTML/HTMLPurifier_AttrDef_HTML_Pixels.h: -------------------------------------------------------------------------------- 1 | // 2 | // HTMLPurifier_AttrDef_HTML_Pixels.h 3 | // HTMLPurifier 4 | // 5 | // Created by Lukas Neumann on 11.01.14. 6 | 7 | 8 | #import "HTMLPurifier_AttrDef.h" 9 | 10 | /** 11 | * Validates an integer representation of pixels according to the HTML spec. 12 | */ 13 | @interface HTMLPurifier_AttrDef_HTML_Pixels : HTMLPurifier_AttrDef 14 | 15 | @property NSNumber* max; 16 | 17 | /** 18 | * @param int $max 19 | */ 20 | - (id)initWithMax:(NSNumber*)newMax; 21 | 22 | /** 23 | * @param string $string 24 | * @param HTMLPurifier_Config $config 25 | * @param HTMLPurifier_Context $context 26 | * @return bool|string 27 | */ 28 | - (NSString*)validateWithString:(NSString*)string config:(HTMLPurifier_Config *)config context:(HTMLPurifier_Context *)context; 29 | 30 | /** 31 | * @param string $string 32 | * @return HTMLPurifier_AttrDef 33 | */ 34 | - (HTMLPurifier_AttrDef*)make:(NSString*)string; 35 | 36 | @end 37 | -------------------------------------------------------------------------------- /HTMLPurifier/Attributes/AttrDef/HTMLPurifier_AttrDef_Clone.h: -------------------------------------------------------------------------------- 1 | // 2 | // HTMLPurifier_AttrDef_Clone.h 3 | // HTMLPurifier 4 | // 5 | // Created by Lukas Neumann on 13.01.14. 6 | 7 | 8 | /** 9 | * Dummy AttrDef that mimics another AttrDef, BUT it generates clones 10 | * with make. 11 | */ 12 | #import "HTMLPurifier_AttrDef.h" 13 | 14 | @interface HTMLPurifier_AttrDef_Clone : HTMLPurifier_AttrDef 15 | 16 | /** 17 | * What we're cloning. 18 | * @type HTMLPurifier_AttrDef 19 | */ 20 | @property HTMLPurifier_AttrDef* clone; 21 | 22 | /** 23 | * @param HTMLPurifier_AttrDef $clone 24 | */ 25 | -(id) initWithClone:(HTMLPurifier_AttrDef*)nclone; 26 | 27 | /** 28 | * @param string $v 29 | * @param HTMLPurifier_Config $config 30 | * @param HTMLPurifier_Context $context 31 | * @return bool|string 32 | */ 33 | -(NSString*) validateWithString:(NSString *)string config:(HTMLPurifier_Config *)config context:(HTMLPurifier_Context *)context; 34 | 35 | /** 36 | * @param string $string 37 | * @return HTMLPurifier_AttrDef 38 | */ 39 | -(HTMLPurifier_AttrDef*) make:(NSString*)string; 40 | 41 | @end 42 | -------------------------------------------------------------------------------- /HTMLPurifier/Attributes/AttrDef/HTMLPurifier_AttrDef_Enum.h: -------------------------------------------------------------------------------- 1 | // 2 | // HTMLPurifier_AttrDef_Enum.h 3 | // HTMLPurifier 4 | // 5 | // Created by Roman Priebe on 10.01.14. 6 | 7 | 8 | #import "HTMLPurifier_AttrDef.h" 9 | 10 | @interface HTMLPurifier_AttrDef_Enum : HTMLPurifier_AttrDef 11 | 12 | @property NSMutableArray* validValues; 13 | @property BOOL caseSensitive; 14 | 15 | - (id)init; 16 | - (id)initWithValidValues:(NSArray*)array; 17 | - (id)initWithValidValues:(NSArray*)array caseSensitive:(BOOL)newCaseSensitive; 18 | 19 | 20 | - (NSString*)validateWithString:(NSString*)string config:(HTMLPurifier_Config*)config context:(HTMLPurifier_Context *)context; 21 | 22 | - (HTMLPurifier_AttrDef_Enum*)make:(NSString*)string; 23 | 24 | 25 | @end 26 | -------------------------------------------------------------------------------- /HTMLPurifier/Attributes/AttrDef/HTMLPurifier_AttrDef_Lang.h: -------------------------------------------------------------------------------- 1 | // 2 | // HTMLPurifier_AttrDef_Lang.h 3 | // HTMLPurifier 4 | // 5 | // Created by Lukas Neumann on 13.01.14. 6 | 7 | 8 | /** 9 | * Validates the HTML attribute lang, effectively a language code. 10 | * @note Built according to RFC 3066, which obsoleted RFC 1766 11 | */ 12 | 13 | #import "HTMLPurifier_AttrDef.h" 14 | 15 | @interface HTMLPurifier_AttrDef_Lang : HTMLPurifier_AttrDef 16 | 17 | /** 18 | * @param string $string 19 | * @param HTMLPurifier_Config $config 20 | * @param HTMLPurifier_Context $context 21 | * @return bool|string 22 | */ 23 | 24 | -(NSString*) validateWithString:(NSString *)string config:(HTMLPurifier_Config *)config context:(HTMLPurifier_Context *)context; 25 | 26 | @end 27 | -------------------------------------------------------------------------------- /HTMLPurifier/Attributes/AttrDef/HTMLPurifier_AttrDef_Switch.h: -------------------------------------------------------------------------------- 1 | // 2 | // HTMLPurifier_AttrDef_Switch.h 3 | // HTMLPurifier 4 | // 5 | // Created by Roman Priebe on 11.01.14. 6 | 7 | 8 | #import "HTMLPurifier_AttrDef.h" 9 | 10 | /** 11 | * Decorator that, depending on a token, switches between two definitions. 12 | */ 13 | @interface HTMLPurifier_AttrDef_Switch : HTMLPurifier_AttrDef 14 | { 15 | 16 | /** 17 | * @type string 18 | */ 19 | NSString* tag; 20 | 21 | /** 22 | * @type HTMLPurifier_AttrDef 23 | */ 24 | HTMLPurifier_AttrDef* withTag; 25 | 26 | /** 27 | * @type HTMLPurifier_AttrDef 28 | */ 29 | HTMLPurifier_AttrDef* withoutTag; 30 | } 31 | 32 | /** 33 | * @param string $tag Tag name to switch upon 34 | * @param HTMLPurifier_AttrDef $with_tag Call if token matches tag 35 | * @param HTMLPurifier_AttrDef $without_tag Call if token doesn't match, or there is no token 36 | */ 37 | - (id)initWithTag:(NSString*)newTag withTag:(HTMLPurifier_AttrDef*)newWithTag withoutTag:(HTMLPurifier_AttrDef*)newWithoutTag; 38 | 39 | /** 40 | * @param string $string 41 | * @param HTMLPurifier_Config $config 42 | * @param HTMLPurifier_Context $context 43 | * @return bool|string 44 | */ 45 | - (NSString*)validateWithString:(NSString *)string config:(HTMLPurifier_Config *)config context:(HTMLPurifier_Context *)context; 46 | 47 | @end 48 | -------------------------------------------------------------------------------- /HTMLPurifier/Attributes/AttrDef/HTMLPurifier_AttrDef_Text.h: -------------------------------------------------------------------------------- 1 | // 2 | // HTMLPurifier_AttrDef_Text.h 3 | // HTMLPurifier 4 | // 5 | // Created by Lukas Neumann on 13.01.14. 6 | 7 | 8 | #import "HTMLPurifier_AttrDef.h" 9 | 10 | @interface HTMLPurifier_AttrDef_Text : HTMLPurifier_AttrDef 11 | 12 | /** 13 | * @param string $string 14 | * @param HTMLPurifier_Config $config 15 | * @param HTMLPurifier_Context $context 16 | * @return bool|string 17 | */ 18 | -(NSString*) validateWithString:(NSString *)string config:(HTMLPurifier_Config *)config context:(HTMLPurifier_Context *)context; 19 | 20 | @end 21 | -------------------------------------------------------------------------------- /HTMLPurifier/Attributes/AttrDef/HTMLPurifier_AttrDef_Text.m: -------------------------------------------------------------------------------- 1 | // 2 | // HTMLPurifier_AttrDef_Text.m 3 | // HTMLPurifier 4 | // 5 | // Created by Lukas Neumann on 13.01.14. 6 | 7 | 8 | #import "HTMLPurifier_AttrDef_Text.h" 9 | 10 | /** 11 | * Validates arbitrary text according to the HTML spec. 12 | */ 13 | 14 | @implementation HTMLPurifier_AttrDef_Text 15 | 16 | /** 17 | * @param string $string 18 | * @param HTMLPurifier_Config $config 19 | * @param HTMLPurifier_Context $context 20 | * @return bool|string 21 | */ 22 | -(NSString*) validateWithString:(NSString *)string config:(HTMLPurifier_Config *)config context:(HTMLPurifier_Context *)context 23 | { 24 | return [super parseCDATAWithString:string]; 25 | } 26 | 27 | @end 28 | -------------------------------------------------------------------------------- /HTMLPurifier/Attributes/AttrDef/HTMLPurifier_AttrDef_URI.h: -------------------------------------------------------------------------------- 1 | // 2 | // HTMLPurifier_AttrDef_URI.h 3 | // HTMLPurifier 4 | // 5 | // Created by Lukas Neumann on 13.01.14. 6 | 7 | 8 | 9 | /** 10 | * Validates a URI as defined by RFC 3986. 11 | * @note Scheme-specific mechanics deferred to HTMLPurifier_URIScheme 12 | */ 13 | 14 | #import "HTMLPurifier_AttrDef.h" 15 | 16 | @class HTMLPurifier_Config, HTMLPurifier_Context, HTMLPurifier_URIParser, HTMLPurifier_AttrDef_URI; 17 | 18 | @interface HTMLPurifier_AttrDef_URI : HTMLPurifier_AttrDef 19 | 20 | /** 21 | * @type HTMLPurifier_URIParser 22 | */ 23 | @property HTMLPurifier_URIParser* parser; 24 | 25 | /** 26 | * @type bool 27 | */ 28 | @property NSNumber* embedsResource; 29 | 30 | /** 31 | * @param bool $embeds_resource Does the URI here result in an extra HTTP request? 32 | */ 33 | -(id)initWithNumber:(NSNumber*)new_embeds_resource; 34 | 35 | /** 36 | * @param string $string 37 | * @return HTMLPurifier_AttrDef_URI 38 | */ 39 | -(HTMLPurifier_AttrDef_URI*) make:(NSString*)string; 40 | 41 | 42 | /** 43 | * @param string $uri 44 | * @param HTMLPurifier_Config $config 45 | * @param HTMLPurifier_Context $context 46 | * @return bool|string 47 | */ 48 | -(NSString*) validateWithString:(NSString *)uri config:(HTMLPurifier_Config *)config context:(HTMLPurifier_Context *)context; 49 | 50 | 51 | 52 | @end 53 | -------------------------------------------------------------------------------- /HTMLPurifier/Attributes/AttrDef/HTMLPurifier_AttrDef_URI_Email.h: -------------------------------------------------------------------------------- 1 | // 2 | // HTMLPurifier_AttrDef_URI_Email.h 3 | // HTMLPurifier 4 | // 5 | // Created by Lukas Neumann on 12.01.14. 6 | 7 | 8 | #import "HTMLPurifier_AttrDef.h" 9 | 10 | @interface HTMLPurifier_AttrDef_URI_Email : HTMLPurifier_AttrDef 11 | 12 | /** 13 | * Unpacks a mailbox into its display-name and address 14 | * @param string $string 15 | * @return mixed 16 | */ 17 | -(NSMutableDictionary*) unpackWithString:(NSString*)string; 18 | 19 | @end 20 | -------------------------------------------------------------------------------- /HTMLPurifier/Attributes/AttrDef/HTMLPurifier_AttrDef_URI_Email.m: -------------------------------------------------------------------------------- 1 | // 2 | // HTMLPurifier_AttrDef_URI_Email.m 3 | // HTMLPurifier 4 | // 5 | // Created by Lukas Neumann on 12.01.14. 6 | 7 | 8 | #import "HTMLPurifier_AttrDef_URI_Email.h" 9 | 10 | @implementation HTMLPurifier_AttrDef_URI_Email 11 | 12 | /** 13 | * Unpacks a mailbox into its display-name and address 14 | * @param string $string 15 | * @return mixed 16 | */ 17 | -(NSMutableDictionary*) unpackWithString:(NSString*)string 18 | { 19 | // needs to be implemented 20 | return nil; 21 | } 22 | 23 | 24 | @end 25 | -------------------------------------------------------------------------------- /HTMLPurifier/Attributes/AttrDef/HTMLPurifier_AttrDef_URI_Email_SimpleCheck.h: -------------------------------------------------------------------------------- 1 | // 2 | // HTMLPurifier_AttrDef_URI_Email_SimpleCheck.h 3 | // HTMLPurifier 4 | // 5 | // Created by Lukas Neumann on 12.01.14. 6 | 7 | 8 | #import "HTMLPurifier_AttrDef_URI_Email.h" 9 | 10 | @interface HTMLPurifier_AttrDef_URI_Email_SimpleCheck : HTMLPurifier_AttrDef_URI_Email 11 | 12 | /** 13 | * @param string $string 14 | * @param HTMLPurifier_Config $config 15 | * @param HTMLPurifier_Context $context 16 | * @return bool|string 17 | */ 18 | -(NSString*) validateWithString:(NSString *)string config:(HTMLPurifier_Config *)config context:(HTMLPurifier_Context *)context; 19 | 20 | @end 21 | -------------------------------------------------------------------------------- /HTMLPurifier/Attributes/AttrDef/HTMLPurifier_AttrDef_URI_Email_SimpleCheck.m: -------------------------------------------------------------------------------- 1 | // 2 | // HTMLPurifier_AttrDef_URI_Email_SimpleCheck.m 3 | // HTMLPurifier 4 | // 5 | // Created by Lukas Neumann on 12.01.14. 6 | 7 | 8 | #import "HTMLPurifier_AttrDef_URI_Email_SimpleCheck.h" 9 | #import "BasicPHP.h" 10 | 11 | @implementation HTMLPurifier_AttrDef_URI_Email_SimpleCheck 12 | 13 | /** 14 | * @param string $string 15 | * @param HTMLPurifier_Config $config 16 | * @param HTMLPurifier_Context $context 17 | * @return bool|string 18 | */ 19 | -(NSString*) validateWithString:(NSString *)string config:(HTMLPurifier_Config *)config context:(HTMLPurifier_Context *)context 20 | { 21 | // no support for named mailboxes i.e. "Bob " 22 | // that needs more percent encoding to be done 23 | if ([string isEqual:@""]) 24 | { 25 | return nil; 26 | } 27 | string = trim(string); 28 | BOOL result = preg_match_2(@"^[A-Z0-9._%-]+@[A-Z0-9.-]+\\.[A-Z]{2,}$", string); 29 | return result ? string : nil; 30 | } 31 | 32 | @end 33 | -------------------------------------------------------------------------------- /HTMLPurifier/Attributes/AttrDef/HTMLPurifier_AttrDef_URI_Host.h: -------------------------------------------------------------------------------- 1 | // 2 | // HTMLPurifier_AttrDef_URI_Host.h 3 | // HTMLPurifier 4 | // 5 | // Created by Lukas Neumann on 12.01.14. 6 | 7 | 8 | #import "HTMLPurifier_AttrDef.h" 9 | #import "HTMLPurifier_AttrDef_URI_IPv4.h" 10 | #import "HTMLPurifier_AttrDef_URI_IPv6.h" 11 | 12 | 13 | @interface HTMLPurifier_AttrDef_URI_Host : HTMLPurifier_AttrDef 14 | 15 | /** 16 | * IPv4 sub-validator. 17 | * @type HTMLPurifier_AttrDef_URI_IPv4 18 | */ 19 | @property HTMLPurifier_AttrDef_URI_IPv4* ipv4; 20 | 21 | /** 22 | * IPv6 sub-validator. 23 | * @type HTMLPurifier_AttrDef_URI_IPv6 24 | */ 25 | @property HTMLPurifier_AttrDef_URI_IPv6* ipv6; 26 | 27 | /** 28 | * @param string $string 29 | * @param HTMLPurifier_Config $config 30 | * @param HTMLPurifier_Context $context 31 | * @return bool|string 32 | */ 33 | -(NSString*) validateWithString:(NSString *)string config:(HTMLPurifier_Config *)config context:(HTMLPurifier_Context *)context; 34 | 35 | 36 | @end 37 | -------------------------------------------------------------------------------- /HTMLPurifier/Attributes/AttrDef/HTMLPurifier_AttrDef_URI_IPv4.h: -------------------------------------------------------------------------------- 1 | // 2 | // HTMLPurifier_AttrDef_URI_IPv4.h 3 | // HTMLPurifier 4 | // 5 | // Created by Lukas Neumann on 12.01.14. 6 | 7 | 8 | #import "HTMLPurifier_AttrDef.h" 9 | 10 | @interface HTMLPurifier_AttrDef_URI_IPv4 : HTMLPurifier_AttrDef 11 | 12 | /** 13 | * IPv4 regex, protected so that IPv6 can reuse it. 14 | * @type string 15 | */ 16 | @property NSString* ip4; 17 | 18 | /** 19 | * @param string $aIP 20 | * @param HTMLPurifier_Config $config 21 | * @param HTMLPurifier_Context $context 22 | * @return bool|string 23 | */ 24 | -(NSString*) validateWithString:(NSString*)aIP config:(HTMLPurifier_Config*)config context:(HTMLPurifier_Context*)context; 25 | 26 | /** 27 | * Lazy load function to prevent regex from being stuffed in 28 | * cache. 29 | */ 30 | -(void) loadRegex; 31 | 32 | 33 | @end 34 | -------------------------------------------------------------------------------- /HTMLPurifier/Attributes/AttrDef/HTMLPurifier_AttrDef_URI_IPv4.m: -------------------------------------------------------------------------------- 1 | // 2 | // HTMLPurifier_AttrDef_URI_IPv4.m 3 | // HTMLPurifier 4 | // 5 | // Created by Lukas Neumann on 12.01.14. 6 | 7 | 8 | /** 9 | * Validates an IPv4 address 10 | * @author Feyd @ forums.devnetwork.net (public domain) 11 | */ 12 | 13 | #import "HTMLPurifier_AttrDef_URI_IPv4.h" 14 | #import "BasicPHP.h" 15 | 16 | @implementation HTMLPurifier_AttrDef_URI_IPv4 17 | 18 | /** 19 | * IPv4 regex, protected so that IPv6 can reuse it. 20 | * @type string 21 | */ 22 | @synthesize ip4; 23 | 24 | /** 25 | * @param string $aIP 26 | * @param HTMLPurifier_Config $config 27 | * @param HTMLPurifier_Context $context 28 | * @return bool|string 29 | */ 30 | -(NSString*) validateWithString:(NSString*)aIP config:(HTMLPurifier_Config*)config context:(HTMLPurifier_Context*)context 31 | { 32 | if (!ip4) 33 | { 34 | [self loadRegex]; 35 | } 36 | 37 | if (preg_match_2_WithLineBreak([NSString stringWithFormat:@"^%@$",ip4],aIP)) 38 | { 39 | return aIP; 40 | } 41 | return nil; 42 | } 43 | 44 | /** 45 | * Lazy load function to prevent regex from being stuffed in 46 | * cache. 47 | */ 48 | -(void) loadRegex 49 | { 50 | NSString* oct = @"(?:(25[0-5]|2[0-4][0-9]|1[0-9]{2}|[1-9][0-9]|[0-9]))"; // 0-255 51 | ip4 = [NSString stringWithFormat:@"(?:%@\\.%@\\.%@\\.%@)",oct,oct,oct,oct]; 52 | } 53 | 54 | 55 | @end 56 | -------------------------------------------------------------------------------- /HTMLPurifier/Attributes/AttrDef/HTMLPurifier_AttrDef_URI_IPv6.h: -------------------------------------------------------------------------------- 1 | // 2 | // HTMLPurifier_AttrDef_URI_IPv6.h 3 | // HTMLPurifier 4 | // 5 | // Created by Lukas Neumann on 12.01.14. 6 | 7 | 8 | #import "HTMLPurifier_AttrDef_URI_IPv4.h" 9 | 10 | @interface HTMLPurifier_AttrDef_URI_IPv6 : HTMLPurifier_AttrDef_URI_IPv4 11 | 12 | /** 13 | * @param string $aIP 14 | * @param HTMLPurifier_Config $config 15 | * @param HTMLPurifier_Context $context 16 | * @return bool|string 17 | */ 18 | -(NSString*) validateWithString:(NSString *)aIP config:(HTMLPurifier_Config *)config context:(HTMLPurifier_Context *)context; 19 | 20 | @end 21 | -------------------------------------------------------------------------------- /HTMLPurifier/Attributes/AttrTransform/HTMLPurifier_AttrTransform.h: -------------------------------------------------------------------------------- 1 | // 2 | // HTMLPurifier_AttrTransform.h 3 | // HTMLPurifier 4 | // 5 | // Created by Roman Priebe on 18.01.14. 6 | 7 | 8 | #import 9 | 10 | @class HTMLPurifier_Config, HTMLPurifier_Context; 11 | 12 | @interface HTMLPurifier_AttrTransform : NSObject 13 | 14 | 15 | - (NSDictionary*)transform:(NSDictionary*)attr sortedKeys:(NSMutableArray*)sortedKeys config:(HTMLPurifier_Config*)config context:(HTMLPurifier_Context*)context; 16 | 17 | - (void)prependCSS:(NSMutableDictionary*)attr sortedKeys:(NSMutableArray*)sortedKeys css:(NSString*)css; 18 | 19 | - (NSObject*)confiscateAttr:(NSMutableDictionary*)attr sortedKeys:(NSMutableArray*)sortedKeys key:(NSString*)key; 20 | 21 | @end 22 | -------------------------------------------------------------------------------- /HTMLPurifier/Attributes/AttrTransform/HTMLPurifier_AttrTransform_Background.h: -------------------------------------------------------------------------------- 1 | // 2 | // HTMLPurifier_AttrTransform_Background.h 3 | // HTMLPurifier 4 | // 5 | // Created by Lukas Neumann on 22.01.14. 6 | 7 | 8 | /** 9 | * Pre-transform that changes proprietary background attribute to CSS. 10 | */ 11 | #import "HTMLPurifier_AttrTransform.h" 12 | 13 | @interface HTMLPurifier_AttrTransform_Background : HTMLPurifier_AttrTransform 14 | 15 | - (NSDictionary*)transform:(NSDictionary*)attr sortedKeys:(NSMutableArray*)sortedKeys config:(HTMLPurifier_Config*)config context:(HTMLPurifier_Context*)context; 16 | 17 | @end 18 | -------------------------------------------------------------------------------- /HTMLPurifier/Attributes/AttrTransform/HTMLPurifier_AttrTransform_Background.m: -------------------------------------------------------------------------------- 1 | // 2 | // HTMLPurifier_AttrTransform_Background.m 3 | // HTMLPurifier 4 | // 5 | // Created by Lukas Neumann on 22.01.14. 6 | 7 | 8 | /** 9 | * Pre-transform that changes proprietary background attribute to CSS. 10 | */ 11 | #import "HTMLPurifier_AttrTransform_Background.h" 12 | 13 | @implementation HTMLPurifier_AttrTransform_Background 14 | 15 | /** 16 | * @param array $attr 17 | * @param HTMLPurifier_Config $config 18 | * @param HTMLPurifier_Context $context 19 | * @return array 20 | */ 21 | - (NSDictionary*)transform:(NSDictionary*)attr sortedKeys:(NSMutableArray*)sortedKeys config:(HTMLPurifier_Config*)config context:(HTMLPurifier_Context*)context 22 | { 23 | if (!attr[@"background"]) 24 | { 25 | return attr; 26 | } 27 | 28 | NSMutableDictionary* attr_m = [attr mutableCopy]; 29 | 30 | NSObject* background = [self confiscateAttr:attr_m sortedKeys:sortedKeys key:@"background"]; 31 | // some validation should happen here 32 | 33 | [self prependCSS:attr_m sortedKeys:sortedKeys css:[NSString stringWithFormat:@"background-image:url(%@);",background]]; 34 | return attr_m; 35 | } 36 | 37 | @end 38 | -------------------------------------------------------------------------------- /HTMLPurifier/Attributes/AttrTransform/HTMLPurifier_AttrTransform_BdoDir.h: -------------------------------------------------------------------------------- 1 | // 2 | // HTMLPurifier_AttrTransform_BdoDir.h 3 | // HTMLPurifier 4 | // 5 | // Created by Lukas Neumann on 22.01.14. 6 | 7 | 8 | #import "HTMLPurifier_AttrTransform.h" 9 | 10 | // this MUST be placed in post, as it assumes that any value in dir is valid 11 | 12 | /** 13 | * Post-trasnform that ensures that bdo tags have the dir attribute set. 14 | */ 15 | @interface HTMLPurifier_AttrTransform_BdoDir : HTMLPurifier_AttrTransform 16 | 17 | - (NSDictionary*)transform:(NSDictionary*)attr sortedKeys:(NSMutableArray*)sortedKeys config:(HTMLPurifier_Config*)config context:(HTMLPurifier_Context*)context; 18 | 19 | @end 20 | -------------------------------------------------------------------------------- /HTMLPurifier/Attributes/AttrTransform/HTMLPurifier_AttrTransform_BdoDir.m: -------------------------------------------------------------------------------- 1 | // 2 | // HTMLPurifier_AttrTransform_BdoDir.m 3 | // HTMLPurifier 4 | // 5 | // Created by Lukas Neumann on 22.01.14. 6 | 7 | 8 | #import "HTMLPurifier_AttrTransform_BdoDir.h" 9 | #import "HTMLPurifier_Config.h" 10 | 11 | // this MUST be placed in post, as it assumes that any value in dir is valid 12 | 13 | /** 14 | * Post-trasnform that ensures that bdo tags have the dir attribute set. 15 | */ 16 | @implementation HTMLPurifier_AttrTransform_BdoDir 17 | 18 | /** 19 | * @param array $attr 20 | * @param HTMLPurifier_Config $config 21 | * @param HTMLPurifier_Context $context 22 | * @return array 23 | */ 24 | - (NSDictionary*)transform:(NSDictionary*)attr sortedKeys:(NSMutableArray*)sortedKeys config:(HTMLPurifier_Config*)config context:(HTMLPurifier_Context*)context 25 | { 26 | if (attr[@"dir"]) 27 | { 28 | return attr; 29 | } 30 | 31 | NSMutableDictionary* attr_m = [attr mutableCopy]; 32 | 33 | [attr_m setValue:[config get:@"Attr.DefaultTextDir"] forKey:@"dir"]; 34 | [sortedKeys addObject:@"dir"]; 35 | 36 | return attr_m; 37 | } 38 | 39 | @end 40 | -------------------------------------------------------------------------------- /HTMLPurifier/Attributes/AttrTransform/HTMLPurifier_AttrTransform_BgColor.h: -------------------------------------------------------------------------------- 1 | // 2 | // HTMLPurifier_AttrTransform_BgColor.h 3 | // HTMLPurifier 4 | // 5 | // Created by Lukas Neumann on 23.01.14. 6 | 7 | 8 | /** 9 | * Pre-transform that changes deprecated bgcolor attribute to CSS. 10 | */ 11 | #import "HTMLPurifier_AttrTransform.h" 12 | 13 | @interface HTMLPurifier_AttrTransform_BgColor : HTMLPurifier_AttrTransform 14 | 15 | - (NSDictionary*)transform:(NSDictionary*)attr sortedKeys:(NSMutableArray*)sortedKeys config:(HTMLPurifier_Config*)config context:(HTMLPurifier_Context*)context; 16 | 17 | @end 18 | -------------------------------------------------------------------------------- /HTMLPurifier/Attributes/AttrTransform/HTMLPurifier_AttrTransform_BgColor.m: -------------------------------------------------------------------------------- 1 | // 2 | // HTMLPurifier_AttrTransform_BgColor.m 3 | // HTMLPurifier 4 | // 5 | // Created by Lukas Neumann on 23.01.14. 6 | 7 | 8 | /** 9 | * Pre-transform that changes deprecated bgcolor attribute to CSS. 10 | */ 11 | #import "HTMLPurifier_AttrTransform_BgColor.h" 12 | 13 | @implementation HTMLPurifier_AttrTransform_BgColor 14 | 15 | /** 16 | * @param array $attr 17 | * @param HTMLPurifier_Config $config 18 | * @param HTMLPurifier_Context $context 19 | * @return array 20 | */ 21 | - (NSDictionary*)transform:(NSDictionary*)attr sortedKeys:(NSMutableArray*)sortedKeys config:(HTMLPurifier_Config*)config context:(HTMLPurifier_Context*)context 22 | { 23 | if (!attr[@"bgcolor"]) 24 | { 25 | return attr; 26 | } 27 | 28 | NSMutableDictionary* attr_m = [attr mutableCopy]; 29 | NSObject* bgcolor = [self confiscateAttr:attr_m sortedKeys:sortedKeys key:@"bgcolor"]; 30 | // some validation should happen here 31 | 32 | [self prependCSS:attr_m sortedKeys:sortedKeys css:[NSString stringWithFormat:@"background-color:%@;",bgcolor]]; 33 | return attr_m; 34 | } 35 | 36 | @end 37 | -------------------------------------------------------------------------------- /HTMLPurifier/Attributes/AttrTransform/HTMLPurifier_AttrTransform_BoolToCSS.h: -------------------------------------------------------------------------------- 1 | // 2 | // HTMLPurifier_AttrTransform_BoolToCSS.h 3 | // HTMLPurifier 4 | // 5 | // Created by Lukas Neumann on 23.01.14. 6 | 7 | 8 | #import "HTMLPurifier_AttrTransform.h" 9 | 10 | /** 11 | * Pre-transform that changes converts a boolean attribute to fixed CSS 12 | */ 13 | @interface HTMLPurifier_AttrTransform_BoolToCSS : HTMLPurifier_AttrTransform 14 | 15 | 16 | /** 17 | * Name of boolean attribute that is trigger. 18 | * @type string 19 | */ 20 | @property NSString* attr; 21 | 22 | /** 23 | * CSS declarations to add to style, needs trailing semicolon. 24 | * @type string 25 | */ 26 | @property NSString* css; 27 | 28 | 29 | -(id) initWithAttr:(NSString*)nattr andCSS:(NSString*)ncss; 30 | 31 | 32 | - (NSDictionary*)transform:(NSDictionary*)attr_d sortedKeys:(NSMutableArray*)sortedKeys config:(HTMLPurifier_Config*)config context:(HTMLPurifier_Context*)context; 33 | 34 | @end 35 | -------------------------------------------------------------------------------- /HTMLPurifier/Attributes/AttrTransform/HTMLPurifier_AttrTransform_Border.h: -------------------------------------------------------------------------------- 1 | // 2 | // HTMLPurifier_AttrTransform_Border.h 3 | // HTMLPurifier 4 | // 5 | // Created by Lukas Neumann on 23.01.14. 6 | 7 | 8 | #import "HTMLPurifier_AttrTransform.h" 9 | 10 | /** 11 | * Pre-transform that changes deprecated border attribute to CSS. 12 | */ 13 | @interface HTMLPurifier_AttrTransform_Border : HTMLPurifier_AttrTransform 14 | 15 | - (NSDictionary*)transform:(NSDictionary*)attr sortedKeys:(NSMutableArray*)sortedKeys config:(HTMLPurifier_Config*)config context:(HTMLPurifier_Context*)context; 16 | 17 | 18 | @end 19 | -------------------------------------------------------------------------------- /HTMLPurifier/Attributes/AttrTransform/HTMLPurifier_AttrTransform_Border.m: -------------------------------------------------------------------------------- 1 | // 2 | // HTMLPurifier_AttrTransform_Border.m 3 | // HTMLPurifier 4 | // 5 | // Created by Lukas Neumann on 23.01.14. 6 | 7 | 8 | #import "HTMLPurifier_AttrTransform_Border.h" 9 | 10 | /** 11 | * Pre-transform that changes deprecated border attribute to CSS. 12 | */ 13 | @implementation HTMLPurifier_AttrTransform_Border 14 | 15 | /** 16 | * @param array $attr 17 | * @param HTMLPurifier_Config $config 18 | * @param HTMLPurifier_Context $context 19 | * @return array 20 | */ 21 | - (NSDictionary*)transform:(NSDictionary*)attr sortedKeys:(NSMutableArray*)sortedKeys config:(HTMLPurifier_Config*)config context:(HTMLPurifier_Context*)context 22 | { 23 | if (!attr[@"border"]) { 24 | return attr; 25 | } 26 | 27 | NSMutableDictionary* attr_m = [attr mutableCopy]; 28 | 29 | NSObject* border_width = [self confiscateAttr:attr_m sortedKeys:sortedKeys key:@"border"]; 30 | // some validation should happen here 31 | [self prependCSS:attr_m sortedKeys:sortedKeys css:[NSString stringWithFormat:@"border:{%@}px solid;",border_width]]; 32 | return attr_m; 33 | } 34 | 35 | @end 36 | -------------------------------------------------------------------------------- /HTMLPurifier/Attributes/AttrTransform/HTMLPurifier_AttrTransform_EnumToCSS.h: -------------------------------------------------------------------------------- 1 | // 2 | // HTMLPurifier_AttrTransform_EnumToCSS.h 3 | // HTMLPurifier 4 | // 5 | // Created by Lukas Neumann on 23.01.14. 6 | 7 | 8 | #import "HTMLPurifier_AttrTransform.h" 9 | 10 | /** 11 | * Generic pre-transform that converts an attribute with a fixed number of 12 | * values (enumerated) to CSS. 13 | */ 14 | @interface HTMLPurifier_AttrTransform_EnumToCSS : HTMLPurifier_AttrTransform 15 | 16 | /** 17 | * Name of attribute to transform from. 18 | * @type string 19 | */ 20 | @property NSString* attr_s; 21 | 22 | /** 23 | * Lookup array of attribute values to CSS. 24 | * @type array 25 | */ 26 | @property NSDictionary* enumToCSS; 27 | 28 | /** 29 | * Case sensitivity of the matching. 30 | * @type bool 31 | * @warning Currently can only be guaranteed to work with ASCII 32 | * values. 33 | */ 34 | @property NSNumber* caseSensitive; // = false; 35 | 36 | - (NSDictionary*)transform:(NSDictionary*)attr sortedKeys:(NSMutableArray*)sortedKeys config:(HTMLPurifier_Config*)config context:(HTMLPurifier_Context*)context; 37 | 38 | -(id) initWithAttr:(NSString*)attr enum:(NSDictionary*)enum_to_css caseSensitive:(NSNumber*)case_sensitive; 39 | 40 | 41 | @end 42 | -------------------------------------------------------------------------------- /HTMLPurifier/Attributes/AttrTransform/HTMLPurifier_AttrTransform_ImgRequired.h: -------------------------------------------------------------------------------- 1 | // 2 | // HTMLPurifier_AttrTransform_ImgRequired.h 3 | // HTMLPurifier 4 | // 5 | // Created by Roman Priebe on 18.01.14. 6 | 7 | 8 | #import "HTMLPurifier_AttrTransform.h" 9 | 10 | @interface HTMLPurifier_AttrTransform_ImgRequired : HTMLPurifier_AttrTransform 11 | 12 | 13 | - (NSDictionary*)transform:(NSDictionary*)attr sortedKeys:(NSMutableArray*)sortedKeys config:(HTMLPurifier_Config*)config context:(HTMLPurifier_Context*)context; 14 | 15 | 16 | @end 17 | -------------------------------------------------------------------------------- /HTMLPurifier/Attributes/AttrTransform/HTMLPurifier_AttrTransform_ImgSpace.h: -------------------------------------------------------------------------------- 1 | // 2 | // HTMLPurifier_AttrTransform_ImgSpace.h 3 | // HTMLPurifier 4 | // 5 | // Created by Lukas Neumann on 23.01.14. 6 | 7 | 8 | #import "HTMLPurifier_AttrTransform.h" 9 | 10 | /** 11 | * Pre-transform that changes deprecated hspace and vspace attributes to CSS 12 | */ 13 | @interface HTMLPurifier_AttrTransform_ImgSpace : HTMLPurifier_AttrTransform 14 | 15 | /** 16 | * @type string 17 | */ 18 | @property NSString* attr_s; 19 | 20 | /** 21 | * @type array 22 | */ 23 | @property NSDictionary* css; 24 | 25 | 26 | - (NSDictionary*)transform:(NSDictionary*)attr sortedKeys:(NSMutableArray*)sortedKeys config:(HTMLPurifier_Config*)config context:(HTMLPurifier_Context*)context; 27 | 28 | -(id) initWithAttr:(NSString*) attr; 29 | 30 | @end 31 | -------------------------------------------------------------------------------- /HTMLPurifier/Attributes/AttrTransform/HTMLPurifier_AttrTransform_ImgTrackingRemoval.h: -------------------------------------------------------------------------------- 1 | // 2 | // HTMLPurifier_AttrTransform_ImgTrackingRemoval.h 3 | // HTMLPurifier 4 | // 5 | // Created by Lukas Neumann on 06.02.16. 6 | // Copyright © 2016 Mynigma. All rights reserved. 7 | // 8 | 9 | #import "HTMLPurifier_AttrTransform.h" 10 | 11 | 12 | @interface HTMLPurifier_AttrTransform_ImgTrackingRemoval : HTMLPurifier_AttrTransform 13 | 14 | 15 | - (NSDictionary*)transform:(NSDictionary*)attr sortedKeys:(NSMutableArray*)sortedKeys config:(HTMLPurifier_Config*)config context:(HTMLPurifier_Context*)context; 16 | 17 | 18 | @end -------------------------------------------------------------------------------- /HTMLPurifier/Attributes/AttrTransform/HTMLPurifier_AttrTransform_Input.h: -------------------------------------------------------------------------------- 1 | // 2 | // HTMLPurifier_AttrTransform_Input.h 3 | // HTMLPurifier 4 | // 5 | // Created by Lukas Neumann on 23.01.14. 6 | 7 | 8 | #import "HTMLPurifier_AttrTransform.h" 9 | 10 | @class HTMLPurifier_AttrDef_HTML_Pixels; 11 | /** 12 | * Performs miscellaneous cross attribute validation and filtering for 13 | * input elements. This is meant to be a post-transform. 14 | */ 15 | @interface HTMLPurifier_AttrTransform_Input : HTMLPurifier_AttrTransform 16 | 17 | /** 18 | * @type HTMLPurifier_AttrDef_HTML_Pixels 19 | */ 20 | @property HTMLPurifier_AttrDef_HTML_Pixels* pixels; 21 | 22 | - (NSDictionary*)transform:(NSDictionary*)attr sortedKeys:(NSMutableArray*)sortedKeys config:(HTMLPurifier_Config*)config context:(HTMLPurifier_Context*)context; 23 | 24 | @end 25 | -------------------------------------------------------------------------------- /HTMLPurifier/Attributes/AttrTransform/HTMLPurifier_AttrTransform_Lang.h: -------------------------------------------------------------------------------- 1 | // 2 | // HTMLPurifier_AttrTransform_Lang.h 3 | // HTMLPurifier 4 | // 5 | // Created by Lukas Neumann on 23.01.14. 6 | 7 | 8 | #import "HTMLPurifier_AttrTransform.h" 9 | 10 | /** 11 | * Post-transform that copies lang's value to xml:lang (and vice-versa) 12 | * @note Theoretically speaking, this could be a pre-transform, but putting 13 | * post is more efficient. 14 | */ 15 | @interface HTMLPurifier_AttrTransform_Lang : HTMLPurifier_AttrTransform 16 | 17 | - (NSDictionary*)transform:(NSDictionary*)attr sortedKeys:(NSMutableArray*)sortedKeys config:(HTMLPurifier_Config*)config context:(HTMLPurifier_Context*)context; 18 | 19 | 20 | @end 21 | -------------------------------------------------------------------------------- /HTMLPurifier/Attributes/AttrTransform/HTMLPurifier_AttrTransform_Lang.m: -------------------------------------------------------------------------------- 1 | // 2 | // HTMLPurifier_AttrTransform_Lang.m 3 | // HTMLPurifier 4 | // 5 | // Created by Lukas Neumann on 23.01.14. 6 | 7 | 8 | #import "HTMLPurifier_AttrTransform_Lang.h" 9 | 10 | /** 11 | * Post-transform that copies lang's value to xml:lang (and vice-versa) 12 | * @note Theoretically speaking, this could be a pre-transform, but putting 13 | * post is more efficient. 14 | */ 15 | @implementation HTMLPurifier_AttrTransform_Lang 16 | 17 | /** 18 | * @param array $attr 19 | * @param HTMLPurifier_Config $config 20 | * @param HTMLPurifier_Context $context 21 | * @return array 22 | */ 23 | - (NSDictionary*)transform:(NSDictionary*)attr sortedKeys:(NSMutableArray*)sortedKeys config:(HTMLPurifier_Config*)config context:(HTMLPurifier_Context*)context 24 | { 25 | NSObject* lang = attr[@"lang"] ? attr[@"lang"] : nil; 26 | 27 | NSObject* xml_lang = attr[@"xml:lang"] ? attr[@"xml:lang"] : nil; 28 | 29 | NSMutableDictionary* attr_m = [attr mutableCopy]; 30 | 31 | if (lang && !xml_lang) 32 | { 33 | [attr_m setObject:lang forKey:@"xml:lang"]; 34 | [sortedKeys addObject:@"xml:lang"]; 35 | } 36 | else if (xml_lang) 37 | { 38 | [attr_m setObject:xml_lang forKey:@"lang"]; 39 | [sortedKeys addObject:@"lang"]; 40 | } 41 | return attr_m; 42 | } 43 | 44 | @end 45 | -------------------------------------------------------------------------------- /HTMLPurifier/Attributes/AttrTransform/HTMLPurifier_AttrTransform_Length.h: -------------------------------------------------------------------------------- 1 | // 2 | // HTMLPurifier_AttrTransform_Length.h 3 | // HTMLPurifier 4 | // 5 | // Created by Lukas Neumann on 23.01.14. 6 | 7 | 8 | #import "HTMLPurifier_AttrTransform.h" 9 | 10 | /** 11 | * Class for handling width/height length attribute transformations to CSS 12 | */ 13 | @interface HTMLPurifier_AttrTransform_Length : HTMLPurifier_AttrTransform 14 | 15 | /** 16 | * @type string 17 | */ 18 | @property NSString* name; 19 | 20 | /** 21 | * @type string 22 | */ 23 | @property NSString* cssName; 24 | 25 | - (NSDictionary*)transform:(NSDictionary*)attr sortedKeys:(NSMutableArray*)sortedKeys config:(HTMLPurifier_Config*)config context:(HTMLPurifier_Context*)context; 26 | 27 | -(id) initWithName:(NSString*)nname css:(NSString*)css_name; 28 | 29 | -(id) initWithName:(NSString*)nname; 30 | 31 | 32 | @end 33 | -------------------------------------------------------------------------------- /HTMLPurifier/Attributes/AttrTransform/HTMLPurifier_AttrTransform_Name.h: -------------------------------------------------------------------------------- 1 | // 2 | // HTMLPurifier_AttrTransform_Name.h 3 | // HTMLPurifier 4 | // 5 | // Created by Lukas Neumann on 23.01.14. 6 | 7 | 8 | #import "HTMLPurifier_AttrTransform.h" 9 | 10 | 11 | /** 12 | * Pre-transform that changes deprecated name attribute to ID if necessary 13 | */ 14 | @interface HTMLPurifier_AttrTransform_Name : HTMLPurifier_AttrTransform 15 | 16 | - (NSDictionary*)transform:(NSDictionary*)attr sortedKeys:(NSMutableArray*)sortedKeys config:(HTMLPurifier_Config*)config context:(HTMLPurifier_Context*)context; 17 | 18 | 19 | @end 20 | -------------------------------------------------------------------------------- /HTMLPurifier/Attributes/AttrTransform/HTMLPurifier_AttrTransform_Name.m: -------------------------------------------------------------------------------- 1 | // 2 | // HTMLPurifier_AttrTransform_Name.m 3 | // HTMLPurifier 4 | // 5 | // Created by Lukas Neumann on 23.01.14. 6 | 7 | 8 | #import "HTMLPurifier_AttrTransform_Name.h" 9 | #import "HTMLPurifier_config.h" 10 | 11 | /** 12 | * Pre-transform that changes deprecated name attribute to ID if necessary 13 | */ 14 | @implementation HTMLPurifier_AttrTransform_Name 15 | 16 | /** 17 | * @param array $attr 18 | * @param HTMLPurifier_Config $config 19 | * @param HTMLPurifier_Context $context 20 | * @return array 21 | */ 22 | - (NSDictionary*)transform:(NSDictionary*)attr sortedKeys:(NSMutableArray*)sortedKeys config:(HTMLPurifier_Config*)config context:(HTMLPurifier_Context*)context 23 | { 24 | // Abort early if we're using relaxed definition of name 25 | if ([config get:@"HTML.Attr.Name.UseCDATA"]) 26 | { 27 | return attr; 28 | } 29 | if (!attr[@"name"]) 30 | { 31 | return attr; 32 | } 33 | 34 | NSMutableDictionary* attr_m = [attr mutableCopy]; 35 | 36 | NSObject* id_c = [self confiscateAttr:attr_m sortedKeys:sortedKeys key:@"name"]; 37 | if (attr_m[@"id"]) 38 | { 39 | return attr_m; 40 | } 41 | if (id_c){ 42 | [attr_m setObject:id_c forKey:@"id"]; 43 | [sortedKeys addObject:@"id"]; 44 | } 45 | return attr_m; 46 | } 47 | 48 | @end 49 | -------------------------------------------------------------------------------- /HTMLPurifier/Attributes/AttrTransform/HTMLPurifier_AttrTransform_NameSync.h: -------------------------------------------------------------------------------- 1 | // 2 | // HTMLPurifier_AttrTransform_NameSync.h 3 | // HTMLPurifier 4 | // 5 | // Created by Roman Priebe on 18.01.14. 6 | 7 | 8 | #import "HTMLPurifier_AttrTransform.h" 9 | 10 | @class HTMLPurifier_AttrDef_HTML_ID; 11 | 12 | /** 13 | * Post-transform that performs validation to the name attribute; if 14 | * it is present with an equivalent id attribute, it is passed through; 15 | * otherwise validation is performed. 16 | */ 17 | @interface HTMLPurifier_AttrTransform_NameSync : HTMLPurifier_AttrTransform 18 | 19 | @property HTMLPurifier_AttrDef_HTML_ID* idDef; 20 | 21 | 22 | - (NSDictionary*)transform:(NSDictionary*)attr sortedKeys:(NSMutableArray*)sortedKeys config:(HTMLPurifier_Config*)config context:(HTMLPurifier_Context*)context; 23 | 24 | 25 | @end 26 | -------------------------------------------------------------------------------- /HTMLPurifier/Attributes/AttrTransform/HTMLPurifier_AttrTransform_Nofollow.h: -------------------------------------------------------------------------------- 1 | // 2 | // HTMLPurifier_AttrTransform_Nofollow.h 3 | // HTMLPurifier 4 | // 5 | // Created by Lukas Neumann on 23.01.14. 6 | 7 | 8 | #import "HTMLPurifier_AttrTransform.h" 9 | 10 | @class HTMLPurifier_URIParser; 11 | 12 | /** 13 | * Adds rel="nofollow" to all outbound links. This transform is 14 | * only attached if Attr.Nofollow is TRUE. 15 | */ 16 | @interface HTMLPurifier_AttrTransform_Nofollow : HTMLPurifier_AttrTransform 17 | 18 | /** 19 | * @type HTMLPurifier_URIParser 20 | */ 21 | @property HTMLPurifier_URIParser* parser; 22 | 23 | - (NSDictionary*)transform:(NSDictionary*)attr sortedKeys:(NSMutableArray*)sortedKeys config:(HTMLPurifier_Config*)config context:(HTMLPurifier_Context*)context; 24 | 25 | 26 | @end 27 | -------------------------------------------------------------------------------- /HTMLPurifier/Attributes/AttrTransform/HTMLPurifier_AttrTransform_SafeEmbed.h: -------------------------------------------------------------------------------- 1 | // 2 | // HTMLPurifier_AttrTransform_SafeEmbed.h 3 | // HTMLPurifier 4 | // 5 | // Created by Lukas Neumann on 23.01.14. 6 | 7 | 8 | #import "HTMLPurifier_AttrTransform.h" 9 | 10 | @interface HTMLPurifier_AttrTransform_SafeEmbed : HTMLPurifier_AttrTransform 11 | 12 | /** 13 | * @type string 14 | */ 15 | @property NSString* name; // = "SafeEmbed"; 16 | 17 | - (NSDictionary*)transform:(NSDictionary*)attr sortedKeys:(NSMutableArray*)sortedKeys config:(HTMLPurifier_Config*)config context:(HTMLPurifier_Context*)context; 18 | 19 | 20 | @end 21 | -------------------------------------------------------------------------------- /HTMLPurifier/Attributes/AttrTransform/HTMLPurifier_AttrTransform_SafeObject.h: -------------------------------------------------------------------------------- 1 | // 2 | // HTMLPurifier_AttrTransform_SafeObject.h 3 | // HTMLPurifier 4 | // 5 | // Created by Lukas Neumann on 23.01.14. 6 | 7 | 8 | #import "HTMLPurifier_AttrTransform.h" 9 | 10 | /** 11 | * Writes default type for all objects. Currently only supports flash. 12 | */ 13 | @interface HTMLPurifier_AttrTransform_SafeObject : HTMLPurifier_AttrTransform 14 | 15 | /** 16 | * @type string 17 | */ 18 | @property NSString* name; // = "SafeObject"; 19 | 20 | - (NSDictionary*)transform:(NSDictionary*)attr sortedKeys:(NSMutableArray*)sortedKeys config:(HTMLPurifier_Config*)config context:(HTMLPurifier_Context*)context; 21 | 22 | 23 | @end 24 | -------------------------------------------------------------------------------- /HTMLPurifier/Attributes/AttrTransform/HTMLPurifier_AttrTransform_SafeObject.m: -------------------------------------------------------------------------------- 1 | // 2 | // HTMLPurifier_AttrTransform_SafeObject.m 3 | // HTMLPurifier 4 | // 5 | // Created by Lukas Neumann on 23.01.14. 6 | 7 | 8 | #import "HTMLPurifier_AttrTransform_SafeObject.h" 9 | 10 | /** 11 | * Writes default type for all objects. Currently only supports flash. 12 | */ 13 | @implementation HTMLPurifier_AttrTransform_SafeObject 14 | 15 | /** 16 | * @type string 17 | */ 18 | @synthesize name; // = "SafeObject"; 19 | 20 | -(id) init 21 | { 22 | self = [super init]; 23 | name = @"SafeObject"; 24 | return self; 25 | } 26 | 27 | /** 28 | * @param array $attr 29 | * @param HTMLPurifier_Config $config 30 | * @param HTMLPurifier_Context $context 31 | * @return array 32 | */ 33 | - (NSDictionary*)transform:(NSDictionary*)attr sortedKeys:(NSMutableArray*)sortedKeys config:(HTMLPurifier_Config*)config context:(HTMLPurifier_Context*)context 34 | { 35 | 36 | if (!attr[@"type"]) 37 | { 38 | NSMutableDictionary* attr_m = [attr mutableCopy]; 39 | [attr_m setObject:@"application/x-shockwave-flash" forKey:@"type"]; 40 | [sortedKeys addObject:@"type"]; 41 | return attr_m; 42 | } 43 | return attr; 44 | } 45 | 46 | @end 47 | -------------------------------------------------------------------------------- /HTMLPurifier/Attributes/AttrTransform/HTMLPurifier_AttrTransform_SafeParam.h: -------------------------------------------------------------------------------- 1 | // 2 | // HTMLPurifier_AttrTransform_SafeParam.h 3 | // HTMLPurifier 4 | // 5 | // Created by Lukas Neumann on 23.01.14. 6 | 7 | 8 | #import "HTMLPurifier_AttrTransform.h" 9 | 10 | @class HTMLPurifier_AttrDef_URI,HTMLPurifier_AttrDef_Enum; 11 | 12 | 13 | /** 14 | * Validates name/value pairs in param tags to be used in safe objects. This 15 | * will only allow name values it recognizes, and pre-fill certain attributes 16 | * with required values. 17 | * 18 | * @note 19 | * This class only supports Flash. In the future, Quicktime support 20 | * may be added. 21 | * 22 | * @warning 23 | * This class expects an injector to add the necessary parameters tags. 24 | */ 25 | @interface HTMLPurifier_AttrTransform_SafeParam : HTMLPurifier_AttrTransform 26 | 27 | /** 28 | * @type string 29 | */ 30 | @property NSString* name; // = "SafeParam"; 31 | 32 | /** 33 | * @type HTMLPurifier_AttrDef_URI 34 | */ 35 | @property HTMLPurifier_AttrDef_URI* uri; 36 | 37 | @property HTMLPurifier_AttrDef_Enum* wmode; 38 | 39 | - (NSDictionary*)transform:(NSDictionary*)attr sortedKeys:(NSMutableArray*)sortedKeys config:(HTMLPurifier_Config*)config context:(HTMLPurifier_Context*)context; 40 | 41 | 42 | @end 43 | -------------------------------------------------------------------------------- /HTMLPurifier/Attributes/AttrTransform/HTMLPurifier_AttrTransform_ScriptRequired.h: -------------------------------------------------------------------------------- 1 | // 2 | // HTMLPurifier_AttrTransform_ScriptRequired.h 3 | // HTMLPurifier 4 | // 5 | // Created by Lukas Neumann on 23.01.14. 6 | 7 | 8 | #import "HTMLPurifier_AttrTransform.h" 9 | 10 | /** 11 | * Implements required attribute stipulation for