From da53b3a637ff0e680469ad18ac20ef50cfb4334a Mon Sep 17 00:00:00 2001
From: Hakim El Hattab <hakim.elhattab@gmail.com>
Date: Mon, 11 Mar 2019 16:12:25 +0100
Subject: [PATCH] validate code line numbers to highlight

---
 plugin/highlight/highlight.js | 19 ++++++++++++-------
 1 file changed, 12 insertions(+), 7 deletions(-)

diff --git a/plugin/highlight/highlight.js b/plugin/highlight/highlight.js
index 49ef64b6..30fe947c 100644
--- a/plugin/highlight/highlight.js
+++ b/plugin/highlight/highlight.js
@@ -115,18 +115,23 @@ var RevealHighlight = (function() {
 
 			linesToHighlight = linesToHighlight || block.getAttribute( 'data-line-numbers' );
 
-			if( typeof linesToHighlight === 'string' ) {
+			if( typeof linesToHighlight === 'string' && linesToHighlight !== '' ) {
 
 				linesToHighlight.split( ',' ).forEach( function( lineNumbers ) {
 
-					lineNumbers = lineNumbers.split( '-' )
+					// Ensure that we looking at a valid slide number (1 or 1-2)
+					if( /^[\d-]+$/.test( lineNumbers ) ) {
 
-					var lineStart = lineNumbers[0];
-					var lineEnd = lineNumbers[1] || lineStart;
+						lineNumbers = lineNumbers.split( '-' )
 
-					[].slice.call( block.querySelectorAll( 'table tr:nth-child(n+'+lineStart+'):nth-child(-n+'+lineEnd+')' ) ).forEach( function( lineElement ) {
-						lineElement.classList.add( 'highlight-line' );
-					} );
+						var lineStart = lineNumbers[0];
+						var lineEnd = lineNumbers[1] || lineStart;
+
+						[].slice.call( block.querySelectorAll( 'table tr:nth-child(n+'+lineStart+'):nth-child(-n+'+lineEnd+')' ) ).forEach( function( lineElement ) {
+							lineElement.classList.add( 'highlight-line' );
+						} );
+
+					}
 
 				} );
 
-- 
GitLab