@@ -4,7 +4,7 @@ import twoKeyReply from '../utils/two-key-reply';
44import errors from '../utils/errors' ;
55import { MContext , Next } from '../types/ctx' ;
66import { isNone } from '../types/option' ;
7- import { decodeUrl } from '../utils/decodeUrl ' ;
7+ import { decodeUrl , encodeUrl } from '../utils/urlencode ' ;
88import sanitize from '../utils/sanitize' ;
99
1010export async function sub ( ctx : MContext , next : Next ) : Promise < void > {
@@ -17,7 +17,9 @@ export async function sub(ctx: MContext, next: Next): Promise<void> {
1717 await ctx . telegram . deleteMessage ( ctx . chat . id , ctx . state . processMsgId ) ;
1818 ctx . state . processMsgId = null ;
1919 ctx . replyWithMarkdown ( `
20- ${ i18n [ lang ] [ 'SUB_SUCCESS' ] } [${ ctx . state . feed . feed_title } ](${ ctx . state . feedUrl } )` ) ;
20+ ${ i18n [ lang ] [ 'SUB_SUCCESS' ] } [${ ctx . state . feed . feed_title } ](${ encodeUrl (
21+ ctx . state . feedUrl
22+ ) } )`) ;
2123 } catch ( e ) {
2224 if ( e instanceof errors . ControllableError ) throw e ;
2325 throw errors . newCtrlErr ( 'DB_ERROR' , e ) ;
@@ -37,7 +39,7 @@ export async function unsub(ctx: MContext, next: Next): Promise<void> {
3739 ctx . state . processMsgId = null ;
3840 ctx . replyWithMarkdown (
3941 `
40- ${ i18n [ lang ] [ 'UNSUB_SUCCESS' ] } [${ feed . value . feed_title } ](${ encodeURI (
42+ ${ i18n [ lang ] [ 'UNSUB_SUCCESS' ] } [${ feed . value . feed_title } ](${ encodeUrl (
4143 ctx . state . feedUrl
4244 ) } )`,
4345 {
@@ -85,15 +87,15 @@ export async function rss(ctx: MContext, next: Next): Promise<void> {
8587 if ( raw ) {
8688 feeds . forEach ( ( feed ) => {
8789 builder . push (
88- `${ sanitize ( feed . feed_title ) } : <a href="${ encodeURI (
90+ `${ sanitize ( feed . feed_title ) } : <a href="${ encodeUrl (
8991 feed . url . trim ( )
9092 ) } ">${ decodeUrl ( feed . url . trim ( ) ) } </a>`
9193 ) ;
9294 } ) ;
9395 } else {
9496 feeds . forEach ( ( feed ) => {
9597 builder . push (
96- `<a href="${ encodeURI ( feed . url . trim ( ) ) } ">${ sanitize (
98+ `<a href="${ encodeUrl ( feed . url . trim ( ) ) } ">${ sanitize (
9799 feed . feed_title
98100 ) } </a>`
99101 ) ;
@@ -144,7 +146,7 @@ export async function viewAll(ctx: MContext, next: Next): Promise<void> {
144146 const url = feed . url . trim ( ) ;
145147 const title = sanitize ( feed . feed_title ) ;
146148 builder . push (
147- `<a href="${ encodeURI ( url ) } ">${ title } </a> ${
149+ `<a href="${ encodeUrl ( url ) } ">${ title } </a> ${
148150 i18n [ lang ] [ 'NUMBER_OF_SUBSCRIBER' ]
149151 } : ${ feed . sub_count } `
150152 ) ;
0 commit comments