Fix EDU-740 NPE on clicking on text inside a tag without href attribute
authorValentina Kiryushkina <valentina.kiryushkina@jetbrains.com>
Tue, 9 Aug 2016 12:27:59 +0000 (15:27 +0300)
committerValentina Kiryushkina <valentina.kiryushkina@jetbrains.com>
Tue, 9 Aug 2016 12:33:38 +0000 (15:33 +0300)
python/educational-core/student/src/com/jetbrains/edu/learning/ui/StudyBrowserWindow.java

index 77cea7b2cf1ea9455fb9aa7a8d2f1c28a1c03f6c..de066f0cfb054af12f1fd96af13383fcbac562e2 100644 (file)
@@ -228,19 +228,21 @@ public class StudyBrowserWindow extends JFrame {
         if (domEventType.equals(EVENT_TYPE_CLICK)) {
           Element target = (Element)ev.getTarget();
           String hrefAttribute = target.getAttribute("href");
-          final Matcher matcher = IN_COURSE_LINK.matcher(hrefAttribute);
-          if (matcher.matches()) {
-            final String lessonName = matcher.group(1);
-            final String taskName = matcher.group(2);
-            StudyNavigator.navigateToTask(myProject, lessonName, taskName);
-          }
-          else {
-            myEngine.setJavaScriptEnabled(true);
-            myEngine.getLoadWorker().cancel();
-            ev.preventDefault();
-            final String href = getLink(target);
-            if (href == null) return;
-            BrowserUtil.browse(href);
+          if (hrefAttribute != null) {
+            final Matcher matcher = IN_COURSE_LINK.matcher(hrefAttribute);
+            if (matcher.matches()) {
+              final String lessonName = matcher.group(1);
+              final String taskName = matcher.group(2);
+              StudyNavigator.navigateToTask(myProject, lessonName, taskName);
+            }
+            else {
+              myEngine.setJavaScriptEnabled(true);
+              myEngine.getLoadWorker().cancel();
+              ev.preventDefault();
+              final String href = getLink(target);
+              if (href == null) return;
+              BrowserUtil.browse(href);
+            }
           }
         }
       }