Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

form_validation lang 'valid_url', but no method #1966

Closed
GDmac opened this issue Nov 5, 2012 · 10 comments
Closed

form_validation lang 'valid_url', but no method #1966

GDmac opened this issue Nov 5, 2012 · 10 comments

Comments

@GDmac
Copy link
Contributor

GDmac commented Nov 5, 2012

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
Copy link
Contributor Author

GDmac commented Nov 5, 2012

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

@narfbg
Copy link
Contributor

narfbg commented Nov 5, 2012

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
Copy link
Contributor Author

GDmac commented Nov 5, 2012

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.

@narfbg
Copy link
Contributor

narfbg commented Nov 5, 2012

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
Copy link
Contributor Author

GDmac commented Nov 5, 2012

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

@narfbg
Copy link
Contributor

narfbg commented Nov 5, 2012

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

@GDmac
Copy link
Contributor Author

GDmac commented Nov 5, 2012

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

@narfbg
Copy link
Contributor

narfbg commented Nov 26, 2012

Implemented, see the above commit.

@narfbg narfbg closed this as completed Nov 26, 2012
nonchip pushed a commit to nonchip/CodeIgniter that referenced this issue Jun 29, 2013
@profnandaa
Copy link

Hey valid_url rule seems not work on my CI 3.0, e.g. an invalid url like "test" passes the test. Advise. @narfbg

@ZombieProtectionAgency
Copy link

@profnandaa I think that is intentional, have a look at Narfs comment on #3478

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants