vojtech-dobes / nette.ajax.js

Flexible AJAX for Nette Framework. Supports snippets, redirects etc.
https://componette.org/vojtech-dobes/nette.ajax.js/
MIT License
149 stars 85 forks source link

validation extension: forbidden colon (:) in URL #125

Open ne0-cz opened 8 years ago

ne0-cz commented 8 years ago

Why is using of : (colon) forbidden in URL? Why should we thank to @vrana for that?

https://github.com/vojtech-dobes/nette.ajax.js/blob/master/nette.ajax.js#L332

How can I at least disable the default URL validation?

It seems to be introduced in commit https://github.com/vojtech-dobes/nette.ajax.js/commit/fdbc555c8a7378a5f7635e7f393513e12ecaeb11 (Local links (with hash) are never ajaxified) which doesn't state anything about colons. The thx to @vrana comment is not helpful at all.

Colon (:) is not seen really often but it is a possible character in URI path (see https://www.quora.com/Is-it-safe-to-use-a-colon-in-the-path-of-a-URL or http://tools.ietf.org/html/rfc3986).

vojtech-dobes commented 8 years ago

Hi, thx to @vrana is reference to http://php.vrana.cz/data/ajaxizace-webexpo.zip. Validation of URL can be disabled - it's partially described in Readme, but list of possible switches is unfortunately missing. Syntax in your case would be following:

<a n:href="hello" class="ajax" data-ajax-validate='{"url":false}'>Hello!</a>

Or in custom call:

$.nette.ajax({
    url: ...,
    validate: {
        url: false,
    },
});

But feel free to send PR if you think that validation should be done better.

I've also opened PR https://github.com/vojtech-dobes/nette.ajax.js/pull/126 where you can change defaults for validation extension.