[Groonga-commit] groonga/gcs [master] q: add unterminated \ escape check

Back to archive index

null+****@clear***** null+****@clear*****
2012年 8月 3日 (金) 22:35:47 JST


Kouhei Sutou	2012-08-03 22:35:47 +0900 (Fri, 03 Aug 2012)

  New Revision: dd2a83b3fa39452ffd756f9e8205c64a2caf9232
  https://github.com/groonga/gcs/commit/dd2a83b3fa39452ffd756f9e8205c64a2caf9232

  Log:
    q: add unterminated \ escape check

  Modified files:
    lib/q-translator.js
    test/q-translator.test.js

  Modified: lib/q-translator.js (+3 -0)
===================================================================
--- lib/q-translator.js    2012-08-03 22:33:29 +0900 (5eca349)
+++ lib/q-translator.js    2012-08-03 22:35:47 +0900 (0ed3dcf)
@@ -51,6 +51,9 @@ QueryTranslator.prototype = {
       if (character == "\\") {
         phrase += character;
         this.offset++;
+        if (this.offset == this.query.length) {
+          this.throwTranslateError("escaped character is missing");
+        }
         character = this.query[this.offset];
       }
       phrase += character;

  Modified: test/q-translator.test.js (+4 -0)
===================================================================
--- test/q-translator.test.js    2012-08-03 22:33:29 +0900 (7c9e731)
+++ test/q-translator.test.js    2012-08-03 22:35:47 +0900 (718ed74)
@@ -98,6 +98,10 @@ suite('QueryTranslator', function() {
                       'star wars"',
                       '|s|tar wars"',
                       "phrase must start with <\">");
+  testPhraseTermError("ended with <\\>",
+                      '"star wars\\',
+                      '"star wars\\||',
+                      "escaped character is missing");
   testPhraseTermError("not terminated",
                       '"star wars',
                       '"star wars||',
-------------- next part --------------
HTML$B$NE:IU%U%!%$%k$rJ]4I$7$^$7$?(B...
下載 



Groonga-commit メーリングリストの案内
Back to archive index