From 3bb3c663cbf813d95bfa647dbb3d47fa06c6cd70 Mon Sep 17 00:00:00 2001 From: Adrian Lang Date: Tue, 13 Sep 2011 12:18:39 +0200 Subject: Add jslint wrapper script --- _test/jslint.js | 89 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 89 insertions(+) create mode 100644 _test/jslint.js (limited to '_test') diff --git a/_test/jslint.js b/_test/jslint.js new file mode 100644 index 000000000..730f8d8a8 --- /dev/null +++ b/_test/jslint.js @@ -0,0 +1,89 @@ +/** + * Copy to a JavaScript console on your DokuWiki instance and execute + * Runs JSLint on all our JavaScript files with our settings + */ + +(function () { +var globals = ['jQuery', 'SIG', 'NS', 'JSINFO', 'LANG', 'DOKU_BASE', + 'DOKU_UHC' // FIXME: Should be moved to JSINFO + ], files = { + 'scripts/behaviour.js': null, + //"scripts/compatibility.js": null, + "scripts/cookie.js": null, + //"scripts/delay.js": null, + //"scripts/drag.js": null, + "scripts/edit.js": null, + "scripts/editor.js": null, + "scripts/helpers.js": null, + "scripts/hotkeys.js": null, + "scripts/index.js": null, + "scripts/linkwiz.js": null, + "scripts/locktimer.js": null, + "scripts/media.js": null, + "scripts/page.js": null, + "scripts/qsearch.js": null, + "scripts/script.js": null, + "scripts/textselection.js": null, + "scripts/toolbar.js": null, + "scripts/tree.js": null //, + //"scripts/tw-sack.js": null + }, overwrites = { + "scripts/script.js": {evil: true}, + "scripts/media.js": {devel: true, windows: true}, + "scripts/locktimer.js": {devel: true}, + "scripts/behaviour.js": {devel: true}, + "scripts/helpers.js": {windows: true} + }; + +jQuery.ajax({ + dataType: 'script', + type: "GET", +// url: 'http://jshint.com/jshint.js' + url: 'https://raw.github.com/douglascrockford/JSLint/master/jslint.js', + success: function () { + for (var file in files) { + jQuery.ajax({ + cache: false, + async: false, + type: "GET", + url: DOKU_BASE + 'lib/' + file, + dataType: 'text', + success: function (res) { + files[file] = res; + var data = lint(files[file]); + jQuery.merge(globals, data.globals); + }}); + } + + for (var file in files) { + if (!files[file]) { + continue; + } + // FIXME more fine-grained write access + var data = lint('/*global ' + globals.join(':true, ') + + ':true*/\n' + files[file], overwrites[file]); + console.log(file); + jQuery.each(data.errors || [], function (_, val) { + if (val === null) { + return; + } + console.error(val.reason + ' (Line ' + (val.line - 1) + + ', character ' + val.character + '):\n' + + val.evidence); + }); + }; + } +}); + +function lint(txt, overwrite) { + JSLINT(txt, jQuery.extend({ + // These settings are necessary + browser: true, + + // Things we probably should learn someday + sloppy: true, white: true, eqeq: true, nomen: true, + plusplus: true, regexp: true + }, overwrite)); + return JSLINT.data(); +} +})(); -- cgit v1.2.3 From b680ea06a64290b3e28a7b7d2d8d33373a3e6709 Mon Sep 17 00:00:00 2001 From: Andreas Gohr Date: Sun, 25 Sep 2011 09:54:17 +0200 Subject: fix namespace cleaning FS#2295 This patch applies the correct pagename cleaning to namespaces as well. Namespaces should follow the same rules as pagenames but due to a bug it was possible to have namespaces ending in a underscore. If you used such a namespace it will be inaccessible after applying this patch. You should rename the namespace directory on the filesystem (removing the trailing underscore). You old links will then work automatically again. Rebuilding the search index is recommended. --- _test/cases/inc/pageutils_clean_id.test.php | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to '_test') diff --git a/_test/cases/inc/pageutils_clean_id.test.php b/_test/cases/inc/pageutils_clean_id.test.php index 01fa7dc1c..ece71e899 100644 --- a/_test/cases/inc/pageutils_clean_id.test.php +++ b/_test/cases/inc/pageutils_clean_id.test.php @@ -36,6 +36,15 @@ class init_clean_id_test extends UnitTestCase { $tests[] = array('page:page',false,'page:page'); $tests[] = array('page;page',false,'page:page'); + $tests[] = array('page._#!','false','page'); + $tests[] = array('._#!page','false','page'); + $tests[] = array('page._#!page','false','page._page'); + $tests[] = array('ns._#!:page','false','ns:page'); + $tests[] = array('ns:._#!page','false','ns:page'); + $tests[] = array('ns._#!ns:page','false','ns._ns:page'); + $tests[] = array('ns_:page',false,'ns:page'); + $tests[] = array('page...page','false','page...page'); + $conf['useslash'] = 0; $tests[] = array('page/page',false,'page_page'); -- cgit v1.2.3 From 475f2b8d83f2500da97ed9df21c9e047b85c2ab2 Mon Sep 17 00:00:00 2001 From: Andreas Gohr Date: Fri, 14 Oct 2011 13:42:11 +0200 Subject: added a test case to check for FS#2349 no problems found --- _test/cases/inc/pageutils_clean_id.test.php | 1 + 1 file changed, 1 insertion(+) (limited to '_test') diff --git a/_test/cases/inc/pageutils_clean_id.test.php b/_test/cases/inc/pageutils_clean_id.test.php index ece71e899..167229c7f 100644 --- a/_test/cases/inc/pageutils_clean_id.test.php +++ b/_test/cases/inc/pageutils_clean_id.test.php @@ -35,6 +35,7 @@ class init_clean_id_test extends UnitTestCase { $tests[] = array('ښ侧化并곦 β',false,'ښ侧化并곦_β'); $tests[] = array('page:page',false,'page:page'); $tests[] = array('page;page',false,'page:page'); + $tests[] = array('page:page 1.2',false,'page:page_1.2'); $tests[] = array('page._#!','false','page'); $tests[] = array('._#!page','false','page'); -- cgit v1.2.3 From 7ae6f87a6c547c0bed9f52e628c050551529259a Mon Sep 17 00:00:00 2001 From: Andreas Gohr Date: Fri, 14 Oct 2011 16:05:57 +0200 Subject: Fixed test and broken salt generation in PassHash class Turned out a test wasn't really testing what it should have been testing and thus did hide a bug. Still puzzles me why it still worked some times. This patch also sets the default iteration count for bmd5 and pmd5 to 8. --- _test/cases/inc/auth_password.test.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to '_test') diff --git a/_test/cases/inc/auth_password.test.php b/_test/cases/inc/auth_password.test.php index 8646e3226..928552a14 100644 --- a/_test/cases/inc/auth_password.test.php +++ b/_test/cases/inc/auth_password.test.php @@ -43,8 +43,7 @@ class auth_password_test extends UnitTestCase { foreach($this->passes as $method => $hash){ $info = "testing method $method"; $this->signal('failinfo',$info); - - $hash = auth_cryptPassword('foo'.$method); + $hash = auth_cryptPassword('foo'.$method,$method); $this->assertTrue(auth_verifyPassword('foo'.$method,$hash)); } } -- cgit v1.2.3 From d98986013f4cf837203b8c4e18bb4d4ef106edc7 Mon Sep 17 00:00:00 2001 From: Anika Henke Date: Sat, 15 Oct 2011 16:00:46 +0100 Subject: added test case for non-breaking spaces in headlines and pagenames (to accompany FS#2291) --- _test/cases/inc/utf8_stripspecials.test.php | 1 + 1 file changed, 1 insertion(+) (limited to '_test') diff --git a/_test/cases/inc/utf8_stripspecials.test.php b/_test/cases/inc/utf8_stripspecials.test.php index 85df75fa1..481f47650 100644 --- a/_test/cases/inc/utf8_stripspecials.test.php +++ b/_test/cases/inc/utf8_stripspecials.test.php @@ -17,6 +17,7 @@ class utf8_stripspecials extends UnitTestCase { $tests[] = array('ascii.string','','\._\-:\*','asciistring'); $tests[] = array('ascii.string',' ','\._\-:\*','ascii string'); $tests[] = array('2.1.14',' ','\._\-:\*','2 1 14'); + $tests[] = array('string with nbsps','_','\*','string_with_nbsps'); foreach($tests as $test){ $this->assertEqual(utf8_stripspecials($test[0],$test[1],$test[2]),$test[3]); -- cgit v1.2.3