@@ -179,4 +179,140 @@ describe('htmllint', () => {
179179 run ( options , expected , '3 errors from 3 files' , done ) ;
180180 } ) ;
181181 } ) ;
182+
183+ describe ( 'file paths with special characters' , ( ) => {
184+ it ( 'with spaces (relative)' , done => {
185+ const filePath = path . normalize ( 'test/fixtures/folder with spaces/test file.html' ) ;
186+ const options = {
187+ files : [ filePath ] ,
188+ errorlevels : [ 'info' , 'warning' , 'error' ]
189+ } ;
190+ const expected = [
191+ {
192+ file : filePath ,
193+ type : 'error' ,
194+ message : expectedResults . invalid [ 1 ] . message ,
195+ lastLine : 7 ,
196+ lastColumn : 39
197+ } ,
198+ {
199+ file : filePath ,
200+ type : 'error' ,
201+ message : expectedResults . invalid [ 2 ] . message ,
202+ lastLine : 7 ,
203+ lastColumn : 39
204+ } ,
205+ {
206+ file : filePath ,
207+ type : 'error' ,
208+ message : expectedResults . invalid [ 3 ] . message ,
209+ lastLine : 8 ,
210+ lastColumn : 20
211+ }
212+ ] ;
213+
214+ run ( options , expected , 'errors from file path with spaces' , done ) ;
215+ } ) ;
216+
217+ it ( 'with spaces (absolute)' , done => {
218+ const filePath = path . resolve ( 'test/fixtures/folder with spaces/test file.html' ) ;
219+ const options = {
220+ files : [ filePath ] ,
221+ absoluteFilePathsForReporter : true ,
222+ errorlevels : [ 'info' , 'warning' , 'error' ]
223+ } ;
224+ const expected = [
225+ {
226+ file : filePath ,
227+ type : 'error' ,
228+ message : expectedResults . invalid [ 1 ] . message ,
229+ lastLine : 7 ,
230+ lastColumn : 39
231+ } ,
232+ {
233+ file : filePath ,
234+ type : 'error' ,
235+ message : expectedResults . invalid [ 2 ] . message ,
236+ lastLine : 7 ,
237+ lastColumn : 39
238+ } ,
239+ {
240+ file : filePath ,
241+ type : 'error' ,
242+ message : expectedResults . invalid [ 3 ] . message ,
243+ lastLine : 8 ,
244+ lastColumn : 20
245+ }
246+ ] ;
247+
248+ run ( options , expected , 'errors from absolute file path with spaces' , done ) ;
249+ } ) ;
250+
251+ it ( 'with various special characters (relative)' , done => {
252+ const filePath = path . normalize ( 'test/fixtures/folder (with) special [chars] & more/test+file#1.html' ) ;
253+ const options = {
254+ files : [ filePath ] ,
255+ errorlevels : [ 'info' , 'warning' , 'error' ]
256+ } ;
257+ const expected = [
258+ {
259+ file : filePath ,
260+ type : 'error' ,
261+ message : expectedResults . invalid [ 1 ] . message . replace ( 'unknownattr' , 'invalidattr' ) ,
262+ lastLine : 7 ,
263+ lastColumn : 39
264+ } ,
265+ {
266+ file : filePath ,
267+ type : 'error' ,
268+ message : expectedResults . invalid [ 2 ] . message ,
269+ lastLine : 7 ,
270+ lastColumn : 39
271+ } ,
272+ {
273+ file : filePath ,
274+ type : 'error' ,
275+ message : expectedResults . invalid [ 3 ] . message ,
276+ lastLine : 8 ,
277+ lastColumn : 21
278+ }
279+ ] ;
280+
281+ run ( options , expected , 'errors from file path with special characters' , done ) ;
282+ } ) ;
283+
284+ it ( 'with various special characters (absolute)' , done => {
285+ const filePath = path . resolve ( 'test/fixtures/folder (with) special [chars] & more/test+file#1.html' ) ;
286+ const options = {
287+ files : [ filePath ] ,
288+ absoluteFilePathsForReporter : true ,
289+ errorlevels : [ 'info' , 'warning' , 'error' ]
290+ } ;
291+ const expected = [
292+ {
293+ file : filePath ,
294+ type : 'error' ,
295+ message : expectedResults . invalid [ 1 ] . message . replace ( 'unknownattr' , 'invalidattr' ) ,
296+ lastLine : 7 ,
297+ lastColumn : 39
298+ } ,
299+ {
300+ file : filePath ,
301+ type : 'error' ,
302+ message : expectedResults . invalid [ 2 ] . message ,
303+ lastLine : 7 ,
304+ lastColumn : 39
305+ } ,
306+ {
307+ file : filePath ,
308+ type : 'error' ,
309+ message : expectedResults . invalid [ 3 ] . message ,
310+ lastLine : 8 ,
311+ lastColumn : 21
312+ }
313+ ] ;
314+
315+ run ( options , expected , 'errors from absolute file path with special characters' , done ) ;
316+ } ) ;
317+ } ) ;
182318} ) ;
0 commit comments