Skip to content

Commit

Permalink
Fix quotemeta issue
Browse files Browse the repository at this point in the history
  • Loading branch information
kirsle committed Jun 18, 2015
1 parent 3abcb54 commit ee78b89
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 4 deletions.
4 changes: 3 additions & 1 deletion Changes.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
# Changes

* 1.1.1 TBD
* 1.1.2 2015-06-18
- Fix a space split issue when parsing tags such as <set> and <get>.
- Fix quotemeta issue that caused an infinite loop when tags contained a
question mark character.

* 1.1.0 2015-04-22
- Add experimental support for UTF-8.
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "rivescript",
"version": "1.1.0",
"version": "1.1.2",
"description": "RiveScript is a scripting language for chatterbots, making it easy to write trigger/response pairs for building up a bot's intelligence.",
"keywords": [
"bot",
Expand Down
2 changes: 1 addition & 1 deletion src/brain.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -686,7 +686,7 @@ class Brain
# Unrecognized tag, preserve it
insert = "\x00#{match}\x01"

reply = reply.replace(new RegExp("<#{match}>"), insert)
reply = reply.replace(new RegExp("<#{utils.quotemeta(match)}>"), insert)

# Recover mangled HTML-like tags
reply = reply.replace(/\x00/g, "<")
Expand Down
2 changes: 1 addition & 1 deletion src/rivescript.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"use strict"

# Constants
VERSION = "1.1.0"
VERSION = "1.1.2"

# Helper modules
Parser = require "./parser"
Expand Down
10 changes: 10 additions & 0 deletions test/test-rivescript.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -386,6 +386,16 @@ exports.test_set_uservars = (test) ->
bot.reply("How old am I?", "You are 5.")
test.done()

exports.test_questionmark = (test) ->
bot = new TestCase(test, """
+ google *
- <a href="https://www.google.com/search?q=<star>">Results are here</a>
""")
bot.reply("google coffeescript",
'<a href="https://www.google.com/search?q=coffeescript">Results are here</a>'
)
test.done()

################################################################################
# Object Macro Tests
################################################################################
Expand Down

0 comments on commit ee78b89

Please sign in to comment.