浏览代码

validate named links according to html id spec #914

Hakim El Hattab 11 年之前
父节点
当前提交
8c9c0ab0a6
共有 1 个文件被更改,包括 3 次插入6 次删除
  1. 3 6
      js/reveal.js

+ 3 - 6
js/reveal.js

@@ -2595,14 +2595,11 @@
 		if( isNaN( parseInt( bits[0], 10 ) ) && name.length ) {
 			var element;
 
-			try {
-				// Find the slide with the specified name
+			// Ensure the named link is a valid HTML ID attribute
+			if( /^[a-zA-Z][\w:.-]*$/.test( name ) ) {
+				// Find the slide with the specified ID
 				element = document.querySelector( '#' + name );
 			}
-			catch( e ) {
-				// If the ID is an invalid selector a harmless SyntaxError
-				// may be thrown here.
-			}
 
 			if( element ) {
 				// Find the position of the named slide and navigate to it