Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fixed persisting infinite loop on $" #18

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions mode/xquery/xquery.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Copyright (C) 2011 by MarkLogic Corporation
Copyright (C) 2011-2013 by MarkLogic Corporation
Author: Mike Brevoort <[email protected]>

Permission is hereby granted, free of charge, to any person obtaining a copy
Expand Down Expand Up @@ -290,11 +290,12 @@ CodeMirror.defineMode("xquery", function(config, parserConfig) {

// tokenizer for variables
function tokenVariable(stream, state) {
var isVariableChar = /[\w\$_-]/;
var isVariableChar = /[\w\$_-]/,
streamIndexOf = function(array,value){ var index = -1; for(var i=0, l=array.length; i < l; i++) { if (array[i] === value) index = i; } return index; };

// a variable may start with a quoted EQName so if the next character is quote, consume to the next quote
if(stream.eat("\"")) {
while(stream.peek() !== undefined && stream.next() !== '\"'){};
while(stream.peek() !== undefined && streamIndexOf(['\"',undefined],stream.next()) === -1){};
stream.eat(":");
} else {
stream.eatWhile(isVariableChar);
Expand Down Expand Up @@ -445,4 +446,4 @@ CodeMirror.defineMode("xquery", function(config, parserConfig) {

});

CodeMirror.defineMIME("application/xquery", "xquery");
CodeMirror.defineMIME("application/xquery", "xquery");