File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -146,7 +146,14 @@ export class Directives {
146146 const [ , handle , suffix ] = source . match ( / ^ ( .* ! ) ( [ ^ ! ] * ) $ / ) as string [ ]
147147 if ( ! suffix ) onError ( `The ${ source } tag has no suffix` )
148148 const prefix = this . tags [ handle ]
149- if ( prefix ) return prefix + decodeURIComponent ( suffix )
149+ if ( prefix ) {
150+ try {
151+ return prefix + decodeURIComponent ( suffix )
152+ } catch ( error ) {
153+ onError ( String ( error ) )
154+ return null
155+ }
156+ }
150157 if ( handle === '!' ) return source // local tag
151158
152159 onError ( `Could not resolve tag: ${ source } ` )
Original file line number Diff line number Diff line change @@ -106,6 +106,12 @@ describe('tags', () => {
106106 expect ( doc . errors [ 0 ] . code ) . toBe ( 'MISSING_CHAR' )
107107 } )
108108 }
109+
110+ test ( 'malformed URI (eemeli/yaml#498)' , ( ) => {
111+ const doc = parseDocument ( '!!%ee 0' )
112+ expect ( doc . errors ) . toHaveLength ( 1 )
113+ expect ( doc . errors [ 0 ] . message ) . toMatch ( 'URIError' )
114+ } )
109115 } )
110116
111117 test ( 'eemeli/yaml#97' , ( ) => {
You can’t perform that action at this time.
0 commit comments