brotkrueml / schema

TYPO3 extension providing an API and view helpers for schema.org markup
https://extensions.typo3.org/extension/schema
GNU General Public License v2.0
32 stars 9 forks source link

[BUG] URL validating is oversensitive #78

Closed ste101 closed 3 years ago

ste101 commented 3 years ago

I tried to set a url propery with a value like this: https://www.test.de Now I'm getting an validation error because of the FILTER_FLAG_PATH_REQUIRED flag. I tried the schema validator and Google rich results an they are both happy with https://www.test.de/ https://www.test.de www.test.de

Because I have old content with a mix of theese spellings it would be good to delete FILTER_FLAG_PATH_REQUIRED in Classes/Model/Manual/TypeLink.php and remove str_starts_with($link, 'http') some lines below.

brotkrueml commented 3 years ago

I assume you are referencing to the Admin Panel? I don't get the problem: The TypeLink is used in Admin Panel's PropertyValueViewHelper where a check of a valid URL is in place beforehand. So this case should not occur.

Please provide an example which illustrates the problem.

ste101 commented 3 years ago

Sorry, I used the API.

        $manufacturer = TypeFactory::createType('LocalBusiness')->setProperties(
        [
            ...
            'url' => $company['0']->getWww(),
            ...
        ]
        );

Then I got the error called by this line \sprintf('The given link "%s" ist not a valid URL!', $link), Then I edited the link to habe the trailing slash and back. Then I removed the flag and it worked without the slash.

brotkrueml commented 3 years ago

Yes, you are right, the check for a URL in https://github.com/brotkrueml/schema/blob/master/Classes/ViewHelpers/AdminPanel/PropertyValueViewHelper.php#L80 is without a path, the check in TypeLink is with the path. This is inconsistent. Will provide a patch.

What version do you need actually? 1 or 2?

ste101 commented 3 years ago

Please remove FILTER_FLAG_PATH_REQUIRED from TypeLink.php. Could you also remove the check for the protocol?

brotkrueml commented 3 years ago

The FILTER_FLAG_PATH_REQUIRED check will be removed, the protocol not.

Reason: In Admin Panel a URL is linked. Without having a proper URL it can't be linked. That should be no problem for you, as www.example.org and example.org are not linked, but http://www.example.org and http://example.org are.

The error comes from inconsistent URL checking. This is the bug and will be fixed.