{"action":"created","issue":{"url":"https://api.github.com/repos/TYPO3Fluid/Fluid/issues/8","labels_url":"https://api.github.com/repos/TYPO3Fluid/Fluid/issues/8/labels{/name}","comments_url":"https://api.github.com/repos/TYPO3Fluid/Fluid/issues/8/comments","events_url":"https://api.github.com/repos/TYPO3Fluid/Fluid/issues/8/events","html_url":"https://github.com/TYPO3Fluid/Fluid/issues/8","id":107900277,"number":8,"title":"Throw exception for unresolved namespaces","user":{"login":"bwaidelich","id":307571,"avatar_url":"https://avatars.githubusercontent.com/u/307571?v=3","gravatar_id":"","url":"https://api.github.com/users/bwaidelich","html_url":"https://github.com/bwaidelich","followers_url":"https://api.github.com/users/bwaidelich/followers","following_url":"https://api.github.com/users/bwaidelich/following{/other_user}","gists_url":"https://api.github.com/users/bwaidelich/gists{/gist_id}","starred_url":"https://api.github.com/users/bwaidelich/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bwaidelich/subscriptions","organizations_url":"https://api.github.com/users/bwaidelich/orgs","repos_url":"https://api.github.com/users/bwaidelich/repos","events_url":"https://api.github.com/users/bwaidelich/events{/privacy}","received_events_url":"https://api.github.com/users/bwaidelich/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":21,"created_at":"2015-09-23T11:32:29Z","updated_at":"2015-11-01T16:03:54Z","closed_at":null,"body":"Unknown namespaces used to be ignored in Fluid. But that lead to serious issues, e.g. when extracting template code into a partial while forgetting the namespace imports.\r\nS.th. like\r\n```html\r\n<media:image image=\"{image}\" />\r\n```\r\nWould try to render '{image}` directly if the `media:image` ViewHelper was ignored, leading to various errors that are very hard to debug.\r\n\r\nWith Flow 3.0 we therefore introduced a stricter handling of unknown namespaces, see: https://jira.neos.io/browse/FLOW-150\r\n\r\n```html\r\n<unknownNamespace:foo />\r\n```\r\n\r\n## Expected output\r\n\r\n```\r\nError while rendering a ViewHelper\r\nThe namespace of ViewHelper notation \"<unknownNamespace:foo.../>\" could not be resolved.\r\n\r\nPossible reasons are:\r\n* you have a spelling error in the viewHelper namespace\r\n* you forgot to import the namespace using \"{namespace unknownNamespace=Some\\Package\\ViewHelpers}\"\r\n* you're trying to use a non-fluid xml namespace, in which case you can use \"{namespace unknownNamespace}\" to ignore this namespace for fluid rendering\r\n```\r\n\r\n## Actual output\r\n\r\n```\r\n<unknownNamespace:foo />\r\n```"},"comment":{"url":"https://api.github.com/repos/TYPO3Fluid/Fluid/issues/comments/152840498","html_url":"https://github.com/TYPO3Fluid/Fluid/issues/8#issuecomment-152840498","issue_url":"https://api.github.com/repos/TYPO3Fluid/Fluid/issues/8","id":152840498,"user":{"login":"mneuhaus","id":316605,"avatar_url":"https://avatars.githubusercontent.com/u/316605?v=3","gravatar_id":"","url":"https://api.github.com/users/mneuhaus","html_url":"https://github.com/mneuhaus","followers_url":"https://api.github.com/users/mneuhaus/followers","following_url":"https://api.github.com/users/mneuhaus/following{/other_user}","gists_url":"https://api.github.com/users/mneuhaus/gists{/gist_id}","starred_url":"https://api.github.com/users/mneuhaus/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mneuhaus/subscriptions","organizations_url":"https://api.github.com/users/mneuhaus/orgs","repos_url":"https://api.github.com/users/mneuhaus/repos","events_url":"https://api.github.com/users/mneuhaus/events{/privacy}","received_events_url":"https://api.github.com/users/mneuhaus/received_events","type":"User","site_admin":false},"created_at":"2015-11-01T16:03:54Z","updated_at":"2015-11-01T16:03:54Z","body":"Hey @bwaidelich :)\r\n\r\nyes we could reproduce that same logic, but it would to the same as my balancing foreach. \r\ni just took a bit of a deeper dive into the TemplateParser to find out how exactly it currently handles namespace declarations and viewhelpers inside cdata an especially inside nested cdata.\r\n\r\n**tl;dr;**\r\n- *any* namespace declaration in simple or nested cdata are evaluated and registered\r\n- nested cdata gets wrangled resulting in broken opened/closed cdata secitons\r\n- ViewHelpers are executed **after** a nested cdata tag\r\n\r\nSo, reproducing the old functionality, would basicall reindtroduce \"buggy\" behavior regarding nested cdata tags, i'd vote in favor of the \"balancing\" foreach loop to handle the cdata/namespace stuff, because it does work as expected as long as your cdata are valid and not imbalanced opened/closed.\r\n\r\n#### Details: \r\n\r\ni tested by using the latest base-distribution and replace the default Welcome Index with : \r\n\r\n```html\r\nsimple cdata\r\n{namespace format=TYPO3\\Fluid\\ViewHelpers\\Format}\r\n-------------------------------------------------------------------------------\r\n|\t<![CDATA[\r\n|\t\t{namespace a=Foo\\A\\ViewHelpers}\r\n|\t\t{namespace format=TYPO3\\Fluid\\ViewHelpers\\Format}\r\n|\t]]>\r\n<format:raw>foobar</format:raw>\r\n-------------------------------------------------------------------------------\r\n<![CDATA[ reset ]]><![CDATA[ reset ]]>\r\n\r\n\r\nproper balanced nested cdata\r\n-------------------------------------------------------------------------------\r\n|\t<![CDATA[\r\n|\t\t{namespace b=Foo\\B\\ViewHelpers}\r\n|\t\t<![CDATA[\r\n|\t\t{namespace c=Foo\\C\\ViewHelpers}\r\n|\t\t]]>\r\n|\t\t{namespace d=Foo\\D\\ViewHelpers}\r\n|\t]]>\r\n-------------------------------------------------------------------------------\r\n<![CDATA[ reset ]]><![CDATA[ reset ]]>\r\n\r\n\r\nunclosed inner cdata\r\n-------------------------------------------------------------------------------\r\n|\t<![CDATA[\r\n|\t\t{namespace e=Foo\\E\\ViewHelpers}\r\n|\t\t<![CDATA[\r\n|\t\t{namespace g=Foo\\G\\ViewHelpers}\r\n|\r\n|\t\t{namespace h=Foo\\H\\ViewHelpers}\r\n|\t]]>\r\n-------------------------------------------------------------------------------\r\n<![CDATA[ reset ]]><![CDATA[ reset ]]>\r\n\r\n\r\nmissing inner open cdata tag\r\n-------------------------------------------------------------------------------\r\n|\t<![CDATA[\r\n|\t\t{namespace i=Foo\\I\\ViewHelpers}\r\n|\r\n|\t\t{namespace j=Foo\\J\\ViewHelpers}\r\n|\t\t]]>\r\n|\t\t{namespace k=Foo\\K\\ViewHelpers}\r\n|\t]]>\r\n-------------------------------------------------------------------------------\r\n<![CDATA[ reset ]]><![CDATA[ reset ]]>\r\n\r\n\r\nraw viewHelper inside cdata\r\n-------------------------------------------------------------------------------\r\n|\t<![CDATA[\r\n|\t\tbefore nested cdata: <f:format.raw>asiodaoijsd</f:format.raw>\r\n|\t\t<![CDATA[\r\n|\t\t\tinside nested cdata<f:format.raw>asiodaoijsd</f:format.raw>\r\n|\t\t]]>\r\n|\t\tafter nested cdata<f:format.raw>asiodaoijsd</f:format.raw>\r\n|\t]]>\r\n-------------------------------------------------------------------------------\r\n<![CDATA[ reset ]]><![CDATA[ reset ]]>\r\n\r\n```\r\n\r\nThe resulting output is: \r\n\r\n```html\r\nsimple cdata\r\n\r\n-------------------------------------------------------------------------------\r\n|\t\r\n|\t\t\r\n|\t\t\r\n|\t\r\nfoobar\r\n-------------------------------------------------------------------------------\r\n reset  reset \r\n\r\n\r\nproper balanced nested cdata\r\n-------------------------------------------------------------------------------\r\n|\t\r\n|\t\t\r\n|\t\t<![CDATA[\r\n|\t\t\r\n|\t\t\r\n|\t\t\r\n|\t]]>\r\n-------------------------------------------------------------------------------\r\n reset  reset \r\n\r\n\r\nunclosed inner cdata\r\n-------------------------------------------------------------------------------\r\n|\t\r\n|\t\t\r\n|\t\t<![CDATA[\r\n|\t\t\r\n|\r\n|\t\t\r\n|\t\r\n-------------------------------------------------------------------------------\r\n reset  reset \r\n\r\n\r\nmissing inner open cdata tag\r\n-------------------------------------------------------------------------------\r\n|\t\r\n|\t\t\r\n|\r\n|\t\t\r\n|\t\t\r\n|\t\t\r\n|\t]]>\r\n-------------------------------------------------------------------------------\r\n reset  reset \r\n\r\n\r\nraw viewHelper inside cdata\r\n-------------------------------------------------------------------------------\r\n|\t\r\n|\t\tbefore nested cdata: <f:format.raw>asiodaoijsd</f:format.raw>\r\n|\t\t<![CDATA[\r\n|\t\t\tinside nested cdata<f:format.raw>asiodaoijsd</f:format.raw>\r\n|\t\t\r\n|\t\tafter nested cdataasiodaoijsd\r\n|\t]]>\r\n-------------------------------------------------------------------------------\r\n reset  reset \r\n```\r\n\r\nadditionally i did a print_r of the registered namespaces inside the TemplateParser after evaluating the template, which resulted in these registered namespaces:\r\n\r\n```php\r\nNamespaces: Array\r\n(\r\n    [f] => TYPO3\\Fluid\\ViewHelpers\r\n    // ... default package namespaces ...\r\n    [format] => TYPO3\\Fluid\\ViewHelpers\\Format\r\n    [a] => Foo\\A\\ViewHelpers\r\n    [b] => Foo\\B\\ViewHelpers\r\n    [c] => Foo\\C\\ViewHelpers\r\n    [d] => Foo\\D\\ViewHelpers\r\n    [e] => Foo\\E\\ViewHelpers\r\n    [g] => Foo\\G\\ViewHelpers\r\n    [h] => Foo\\H\\ViewHelpers\r\n    [i] => Foo\\I\\ViewHelpers\r\n    [j] => Foo\\J\\ViewHelpers\r\n    [k] => Foo\\K\\ViewHelpers\r\n)\r\n```"}}