Skip to content

Commit

Permalink
Fixed escaping issues
Browse files Browse the repository at this point in the history
  • Loading branch information
bostrot committed Sep 20, 2022
1 parent 68b123f commit 15a1dbe
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 6 deletions.
3 changes: 0 additions & 3 deletions .eslintrc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,3 @@ parserOptions:
plugins:
- "@typescript-eslint"
- "prettier"
rules: {
linebreak-style: ["error", "windows"]
}
2 changes: 1 addition & 1 deletion config/config-sample.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ owner_id: 'YOUR_TELEGRAM_ID'
spam_time: 5 * 60 * 1000 # time (in MS) in which user may send 5 messages
spam_cant_msg: 5

parse_mode: 'MarkdownV2' # DO NOT CHANGE!
parse_mode: 'Markdown' # Experimental. Do not change unless you know what you are doing. Options: Markdown/MarkdownV2/HTML

allow_private: false # Allow / disallow option for staff to chat privately
direct_reply: false # Set this to true to just forward staff users to a user chat when allow_private
Expand Down
5 changes: 3 additions & 2 deletions src/middleware.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ const escapeText = function(str: string | string[]) {
.replace(/</g, '&lt;')
.replace(/>/g, '&gt;')
.replace(/"/g, '&quot;');
} else {
} else if (cache.config.parse_mode == 'MarkdownV2') {
// '[', ']', '(', ')', are skipped as they are usally for urls
// '_', '*', '~', '`', are used for actualy markdown
const chars = ['>', '#', '+', '-', '=', '|', '{', '}', '.', '!'];
Expand All @@ -47,7 +47,8 @@ const escapeText = function(str: string | string[]) {
}
}
return newStr;
}
}
return str.toString();
};

// handle messages to web socket
Expand Down

0 comments on commit 15a1dbe

Please sign in to comment.