@@ -211,6 +211,7 @@ exports.sendScript = function (aReq, aRes, aNext) {
211
211
let accept = aReq . headers . accept ;
212
212
let accepts = null ;
213
213
let hasAcceptUserScriptMeta = false ;
214
+ let hasAcceptNotAcceptable = false ;
214
215
let url = URL . parse ( aReq . url ) ;
215
216
216
217
let isLib = aReq . params . isLib || / ^ \/ l i b s \/ / . test ( url . pathname ) ;
@@ -221,10 +222,32 @@ exports.sendScript = function (aReq, aRes, aNext) {
221
222
if ( accept ) {
222
223
accepts = accept . split ( ',' ) ;
223
224
accepts . forEach ( function ( aElement , aIndex , aArray ) {
224
- if ( / ^ t e x t \/ x \- u s e r s c r i p t \- m e t a / . test ( aElement . trim ( ) ) ) { // TODO: toggle `\-meta` in re
225
+ let acceptItem = aElement . trim ( ) ;
226
+
227
+ if ( / ^ t e x t \/ x \- u s e r s c r i p t \- m e t a / . test ( acceptItem ) ) { // TODO: toggle `\-meta` in re
225
228
hasAcceptUserScriptMeta = true ;
226
229
}
230
+
231
+ // Find 406 (not acceptables)
232
+ if ( / ^ i m a g e \/ / . test ( acceptItem ) ) {
233
+ hasAcceptNotAcceptable = true ;
234
+ }
235
+
227
236
} ) ;
237
+ } else {
238
+ console . warn ( [
239
+ 'WARNING:' ,
240
+ ' ' + aReq . connection . remoteAddress ,
241
+ ' ' + aReq . headers . accept ,
242
+ ' ' + aReq . _parsedUrl . pathname ,
243
+ ' ' + aReq . headers [ 'user-agent' ]
244
+ ] . join ( '\n' ) ) ;
245
+ }
246
+
247
+ // Test for 406 (not acceptables)
248
+ if ( hasAcceptNotAcceptable && rUserJS . test ( url . pathname ) ) {
249
+ aRes . status ( 406 ) . send ( ) ;
250
+ return ;
228
251
}
229
252
230
253
if ( hasAcceptUserScriptMeta && rUserJS . test ( url . pathname ) ||
0 commit comments