2nd crack at ajaxifying links and forms (made harder since some lessons produce a 2nd form and links based on earlier input

This commit is contained in:
Rick Lawson 2014-09-25 21:25:22 -04:00
parent 019a148c9d
commit b5c40760a6
3 changed files with 188 additions and 187 deletions

View File

@ -35,8 +35,8 @@ import org.owasp.webgoat.lessons.AbstractLesson;
*
* Getting Source ==============
*
* Source for this application is maintained at https://github.com/WebGoat/WebGoat, a repository
* for free software projects.
* Source for this application is maintained at
* https://github.com/WebGoat/WebGoat, a repository for free software projects.
*
* For details, please see http://webgoat.github.io
*
@ -202,12 +202,11 @@ public abstract class Screen {
}
// TODO we could hook all forms here with javascript call to ajax forms plugin
// hook all the links
public String getContent() {
String makeFormsAjax = "<script> $(document).ready(function() { makeFormsAjax(); });</script>";
// handle this on the page with js
makeFormsAjax = "";
return (content == null) ? "" : content.toString() + makeFormsAjax;
String makeAllAjax = "<script>goat.utils.makeFormsAjax();goat.utils.ajaxifyAttackHref();</script>";
// need to do this here as some of the lessons render forms after submission of an ajax form
return (content == null) ? "" : content.toString() + makeAllAjax;
}
/**

View File

@ -354,7 +354,8 @@
// make any embedded forms ajaxy
goat.utils.showLessonCookiesAndParams();
goat.utils.makeFormsAjax();
goat.utils.ajaxifyAttackHref(); //TODO find some way to hook scope for current menu. Likely needs larger refactor which is already started/stashed
// links are hooked with each lesson now (see Java class Screen.getContent())
//goat.utils.ajaxifyAttackHref(); //TODO find some way to hook scope for current menu. Likely needs larger refactor which is already started/stashed
//refresh menu
angular.element($('#leftside-navigation')).scope().renderMenu();
}

View File

@ -84,7 +84,8 @@ var goatMenu = function($scope, $http, $modal, $log, $templateCache) {
$("#lesson_content").html(reply.data);
//hook forms
goat.utils.makeFormsAjax();// inject form?
goat.utils.ajaxifyAttackHref();
// links are hooked with each lesson now (see Java class Screen.getContent())
//goat.utils.ajaxifyAttackHref();
$('#leftside-navigation').height($('#main-content').height() + 15)//TODO: get ride of fixed value (15)here
//notifies goatLesson Controller of the less change
$scope.$emit('lessonUpdate', {params: curScope.parameters, 'showControls': showControls});