@@ -283,23 +283,31 @@ class MessageBodyReaderRead extends Method {
283283 }
284284}
285285
286+ private string getContentTypeString ( Expr e ) {
287+ result = e .( CompileTimeConstantExpr ) .getStringValue ( )
288+ or
289+ exists ( Field jaxMediaType |
290+ // Accesses to static fields on `MediaType` class do not have constant strings in the database
291+ // so convert the field name to a content type string
292+ jaxMediaType .getDeclaringType ( ) .hasQualifiedName ( getAJaxRsPackage ( "core" ) , "MediaType" ) and
293+ jaxMediaType .getAnAccess ( ) = e and
294+ // e.g. MediaType.TEXT_PLAIN => text/plain
295+ result = jaxMediaType .getName ( ) .toLowerCase ( ) .replaceAll ( "_value" , "" ) .replaceAll ( "_" , "/" )
296+ )
297+ }
298+
286299/** An `@Produces` annotation that describes which content types can be produced by this resource. */
287300class JaxRSProducesAnnotation extends JaxRSAnnotation {
288301 JaxRSProducesAnnotation ( ) { this .getType ( ) .hasQualifiedName ( getAJaxRsPackage ( ) , "Produces" ) }
289302
290303 /**
291304 * Gets a declared content type that can be produced by this resource.
292305 */
293- string getADeclaredContentType ( ) {
294- result = this .getAValue ( ) .( CompileTimeConstantExpr ) .getStringValue ( )
295- or
296- exists ( Field jaxMediaType |
297- // Accesses to static fields on `MediaType` class do not have constant strings in the database
298- // so convert the field name to a content type string
299- jaxMediaType .getDeclaringType ( ) .hasQualifiedName ( getAJaxRsPackage ( "core" ) , "MediaType" ) and
300- jaxMediaType .getAnAccess ( ) = this .getAValue ( ) and
301- // e.g. MediaType.TEXT_PLAIN => text/plain
302- result = jaxMediaType .getName ( ) .toLowerCase ( ) .replaceAll ( "_" , "/" )
306+ Expr getADeclaredContentTypeExpr ( ) {
307+ (
308+ result = this .getAValue ( ) and not result instanceof ArrayInit
309+ or
310+ result = this .getAValue ( ) .( ArrayInit ) .getAnInit ( )
303311 )
304312 }
305313}
@@ -319,7 +327,8 @@ private class JaxRSXssSink extends XssSink {
319327 |
320328 not exists ( resourceMethod .getProducesAnnotation ( ) )
321329 or
322- resourceMethod .getProducesAnnotation ( ) .getADeclaredContentType ( ) = "text/plain"
330+ getContentTypeString ( resourceMethod .getProducesAnnotation ( ) .getADeclaredContentTypeExpr ( ) ) =
331+ "text/plain"
323332 )
324333 }
325334}
0 commit comments