Category: Javascript

Undefined and cache/xxx and invalid %-encoding weird requests

Recently I've been having a lot of weird looking requests that would end up reported in Errbit. Initially I thought that it is my fault but after double checking all the JS code, I would still get those errors.

Fixing this is quite easy. Undefined/cache/xxx requests come from Complitly malware chrome plugin. Solution to this is quite simple (source). Just add this to every page you have (or every with a form):

<script type="text/javascript">
    window.suggestmeyes_loaded = true;
</script>

this will stop the malware script.

The second issue:

ArgumentError: invalid %-encoding (arizona1�0���U��� scottsdale1%0#��U� ��starfield
technologies, inc.1301��U���*http://certs.starfieldtech.com/repository/1402��U���+starfield
secure certificate authority - g2/html>)

The rest of weird requests was coming from EasouSpider crawling engine. So just:

User-agent: EasouSpider
Disallow: /

and don't care anymore.

Rails3, rails.js i document.on is not a function

Pracując dzisiaj nad Senpuu v5 - zauważyłem że Susanoo (autorski CMS pod Senpuu) nie pokazuje JSowych confirmów. Przykładowo coś takiego:

link_to "Usuń notkę", :confirm=>"Czy jesteś pewien?", :method=>"delete"

nie działało. JS ładował się prawidłowo, jednak po włączeniu Firebuga, natknąłem się na taki oto błąd:

document.on is not a function

A po kliknięciu, zamiast wysyłać żądanie usunięcia, realizowane było normalne "linkowe".

Firebug dokładnie wskazywał na tę metodę:

document.on("click", "a[data-method]", function(event, element) {
  if (event.stopped) return;
    handleMethod(element);
    event.stop();
  });

Okazało się, że Rails3 korzysta z nowego Prototype 1.7 - a ja przez przypadek wkleiłem stare. Komunikat zniknął po przywróceniu nowej wersji Prototype. Wziąć ją można z internetu lub generując sobie nowy projekt:

rails new givemeprototype

i kopiując odpowiednie pliki z /public/javascripts/.

Copyright © 2024 Closer to Code

Theme by Anders NorenUp ↑