Skip to content
This repository

form_validation lang 'valid_url', but no method #1966

Closed
GDmac opened this Issue · 8 comments

2 participants

GDmac Andrey Andreev
GDmac

While trying to test issue #1850 i saw that the reporter uses
a valid_url rule in the form validation set_rules

There is no method or function named valid_url() anywhere, so the rule will actually never validate to TRUE.
However, there is a language line for valid_url here:
https://github.com/EllisLab/CodeIgniter/blob/develop/system/language/english/form_validation_lang.php#L33

shouldn't either that line be removed to prevent confusion, or a method be added to actually test for valid_url() ?

GDmac

Additionally, if a rule can't be found, the form validation class logs a message,
but at the debug level. Shouldn't that be raised to the error level?
https://github.com/EllisLab/CodeIgniter/blob/develop/system/libraries/Form_validation.php#L731

Andrey Andreev
Collaborator

Well, that's strange ... there was never a valid_url rule, but that language line has existed during all the time since CI 1.0.

GDmac

Did some diggin. It looks like some apps use the lang line independently from form_validation.
for instance when a non-existant id is requested /app/products/show/233 it just shows lang('invalid_url')

maybe add a method to form_validation then?

  • filter_var($str, FILTER_VALIDATE_URL)
  • filter_var($str, FILTER_VALIDATE_URL, FILTER_FLAG_PATH_REQUIRED)

edit: FILTER_VALIDATE_URL is maybe not appropriate.

Andrey Andreev
Collaborator

invalid_url has nothing to do with this.

Otherwise, I guess we can add a valid_url() method and I do understand your concerns over FILTER_VALIDATE_URL, but I still think it should be used, even if in combination with some additional check.

GDmac

As mentioned above, i'ld like to suggest raising the error level when using rules with non-existing functions.

Andrey Andreev
Collaborator

You no longer want to implement and submit a PR with the rule method? You could include the error-level change in there.

GDmac

yes, will do. Need some time. seems there are some issues with filter_var in php 5.2.13
edit: https://bugs.php.net/bug.php?id=51192

Andrey Andreev
Collaborator

Implemented, see the above commit.

Kyra Zimmer nonchip referenced this issue from a commit in nonchip/CodeIgniter
Andrey Andreev narfbg Add 'valid_url' rule to Form Validation (issue #1966) 296313a
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.