check if the content type is permitted

@param contentType
@throws PageException
14735
private static void checkContentType(String contentType, String accept, String ext, boolean strict) throws PageException {

	if (!StringUtil.isEmpty(ext, true)) {
	    ext = ext.trim().toLowerCase();
	    if (ext.startsWith("*.")) ext = ext.substring(2);
	    if (ext.startsWith(".")) ext = ext.substring(1);

		String blacklistedTypes = SystemUtil.getSystemPropOrEnvVar(
				SystemUtil.SETTING_UPLOAD_EXT_BLACKLIST, SystemUtil.DEFAULT_UPLOAD_EXT_BLACKLIST
		).toLowerCase();
		Array blacklist = ListUtil.listToArrayRemoveEmpty(blacklistedTypes, ',');

		for (int i=blacklist.size(); i > 0; i--) {
			if (ext.equals(Caster.toString(blacklist.getE(i)).trim())){
				throw new ApplicationException("Upload of files with extension [" + ext + "] is not permitted.  "
						+ "You can configure the "
						+ SystemUtil.SETTING_UPLOAD_EXT_BLACKLIST
						+ " System property or the "
						+ SystemUtil.convertSystemPropToEnvVar(SystemUtil.SETTING_UPLOAD_EXT_BLACKLIST)
						+ " Environment variable to allow that file type."
				);
			}
		}
	}
	else ext = null;

	if (StringUtil.isEmpty(accept, true)) return;

	MimeType mt = MimeType.getInstance(contentType), sub;

	Array whishedTypes = ListUtil.listToArrayRemoveEmpty(accept, ',');
	int len = whishedTypes.size();
	for (int i = 1; i <= len; i++) {
	    String whishedType = Caster.toString(whishedTypes.getE(i)).trim().toLowerCase();
	    if (whishedType.equals("*")) return;
	    // check mimetype
	    if (ListUtil.len(whishedType, "/", true) == 2) {
		sub = MimeType.getInstance(whishedType);
		if (mt.match(sub)) return;
	    }

	    // check extension
	    if (ext != null && !strict) {
		if (whishedType.startsWith("*.")) whishedType = whishedType.substring(2);
		if (whishedType.startsWith(".")) whishedType = whishedType.substring(1);
		if (ext.equals(whishedType)) return;
	    }
	}
	throw new ApplicationException("The MIME type of the uploaded file [" + contentType + "] was not accepted by the server.",
		"only this [" + accept + "] mime type are accepted");
    }
992283
public void setContentType(String contentType) 
    {
        if (isCommitted() || contentType==null)
            return;
        
        int semi=contentType.indexOf(';');
        if (semi>0)
        {
            int charset0=contentType.indexOf("charset=",semi);
            if (charset0>0)
            {
                if (_outputState==WRITER_OUT)
                {
                    // need to strip charset= from params
                    int charset1=contentType.indexOf(' ',charset0);
                    
                    if ((charset0==semi+1 && charset1<0) ||
                        (charset0==semi+2 && charset1<0 && contentType.charAt(semi+1)==' ' ))
                        _httpResponse.setContentType(contentType.substring(0,semi));
                    else if (charset1<0)
                        _httpResponse.setContentType(contentType.substring(0, charset0).trim());
                    else
                        _httpResponse.setContentType(contentType.substring(0, charset0)+contentType.substring(charset1));
                }
                else
                {
                    _charEncodingSetInContentType=true;
                    _httpResponse.setContentType(contentType);
                }
            }
            else
                _httpResponse.setContentType(contentType);
        }
        else
            _httpResponse.setContentType(contentType);
        
        if (_locale!=null)
            setLocale(_locale);
    }
1313144
public Tag use(String tagClassName, String tagBundleName, String tagBundleVersion, String fullname, int attrType) throws PageException {
	return use(tagClassName, tagBundleName, tagBundleVersion, fullname, attrType, null);
    }
436878
public final B contentType(MediaType contentType) {
        requireNonNull(contentType, "contentType");
        autoDetectedContentType(false);
        getOrCreateHeaders().contentType(contentType);
        return self();
    }
1179326
@Pure
	protected boolean isActionBodyAllowed(XtendTypeDeclaration type) {
		return !(type instanceof SarlAnnotationType
			|| type instanceof SarlCapacity
			|| type instanceof SarlEvent
			|| type instanceof SarlInterface);
	}
983888
public void setType(String type) throws PageException {
	if (type == null) return;
	try {
	    this.type = toType(type);
	}
	catch (SearchException e) {
	    throw Caster.toPageException(e);
	}
    }
1276385
public static Action contentType(final String contentType) {
        return new Action(r -> {
            r.setContentType(contentType);
            return r;
        });
    }
610483
public void setContentType(String contentType) 
    {
        if (isCommitted())
            return;
        
        if (contentType==null)
        {
            _mimeType=null;
            _header.remove(HttpFields.__ContentType);
        }
        else
        {
            // Look for encoding in contentType
            int i0=contentType.indexOf(';');
            
            if (i0>0)
            {
                // Strip params off mimetype
                _mimeType=contentType.substring(0,i0).trim();
                
                // Look for charset
                int i1=contentType.indexOf("charset=",i0);
                if (i1>=0)
                {
                    i1+=8;
                    int i2 = contentType.indexOf(' ',i1);
                    _characterEncoding = (0<i2)
                    ? contentType.substring(i1,i2)
                                    : contentType.substring(i1);
                    _characterEncoding = QuotedStringTokenizer.unquote(_characterEncoding);
                }
                else // No encoding in the params.
                {
                    if (_characterEncoding!=null)
                        // Add any previously set encoding.
                        contentType+=";charset="+QuotedStringTokenizer.quote(_characterEncoding,";= ");
                }
            }
            else // No encoding and no other params
            {
                _mimeType=contentType;
                // Add any previously set encoding.
                if (_characterEncoding!=null)
                    contentType+=";charset="+QuotedStringTokenizer.quote(_characterEncoding,";= ");
            }
            
            _header.put(HttpFields.__ContentType,contentType);
        }
    }
236193
private void doGetAll() throws PageException {
	if (name == null) throw new ApplicationException("attribute name is required for tag registry, when action is [getAll]");

	try {
	    RegistryEntry[] entries = RegistryQuery.getValues(branch, type);
	    if (entries != null) {
		lucee.runtime.type.Query qry = new QueryImpl(new String[] { "entry", "type", "value" }, new String[] { "VARCHAR", "VARCHAR", "OTHER" }, entries.length, "query");
		for (int i = 0; i < entries.length; i++) {
		    RegistryEntry e = entries[i];
		    int row = i + 1;
		    qry.setAt(KeyConstants._entry, row, e.getKey());
		    qry.setAt(KeyConstants._type, row, RegistryEntry.toCFStringType(e.getType()));
		    qry.setAt(KeyConstants._value, row, e.getValue());
		}

		// sort
		if (sort != null) {
		    String[] arr = sort.toLowerCase().split(",");
		    for (int i = arr.length - 1; i >= 0; i--) {
			String[] col = arr[i].trim().split("\\s+");
			if (col.length == 1) qry.sort(KeyImpl.init(col[0].trim()));
			else if (col.length == 2) {
			    String order = col[1].toLowerCase().trim();
			    if (order.equals("asc")) qry.sort(KeyImpl.init(col[0]), lucee.runtime.type.Query.ORDER_ASC);
			    else if (order.equals("desc")) qry.sort(KeyImpl.init(col[0]), lucee.runtime.type.Query.ORDER_DESC);
			    else throw new ApplicationException("invalid order type [" + col[1] + "]");
			}
		    }
		}

		pageContext.setVariable(name, qry);
	    }
	}
	catch (Exception e) {
	    throw Caster.toPageException(e);
	}

    }
52797
public Response contentType(String contentType) {
        checkCommitted();

        header(HttpConstants.Header.CONTENT_TYPE, contentType);
        httpServletResponse.setContentType(contentType);

        return this;
    }
1133950
public function setContentType(string $content_type)
    {
        if (empty($content_type)) {
            Throw new HeaderException('Empty content type is not allowed.');
        }

        $this->content_type = $content_type;
    }
250362
public boolean isTextContentType(String contentType) {
        if (contentType != null) {
            String lowerContentType = contentType.toLowerCase();
            for (String textContentType : this.parsableContentTypes) {
                if (lowerContentType.startsWith(textContentType)) {
                    return true;
                }
            }
        }
        return false;
    }
200042
public function contentType(string $content_type, string $charset = '')
    {
        $header = new ContentType($content_type);

        if (!empty($charset)) {
            $header->setCharset($charset);
        }

        $this->addHeader($header);
    }
139525
public static byte getSerializeTypeByContentType(String contentType) throws SofaRpcException {
        if (StringUtils.isNotBlank(contentType)) {
            String ct = contentType.toLowerCase();
            if (ct.contains("text/plain") || ct.contains("text/html") || ct.contains("application/json")) {
                return getSerializeTypeByName(RpcConstants.SERIALIZE_JSON);
            } else if (ct.contains(RpcConstants.SERIALIZE_PROTOBUF)) {
                return getSerializeTypeByName(RpcConstants.SERIALIZE_PROTOBUF);
            } else if (ct.contains(RpcConstants.SERIALIZE_HESSIAN)) {
                return getSerializeTypeByName(RpcConstants.SERIALIZE_HESSIAN2);
            }
        }
        throw new SofaRpcException(RpcErrorType.SERVER_DESERIALIZE, "Unsupported content type " + contentType
            + " in http protocol, please set HTTP HEAD: '" + RemotingConstants.HEAD_SERIALIZE_TYPE + "'.");
    }
389512
private void setContentType(String contentType) {
        // The content type may contain the charset, parse it and set it.
        if (contentType != null && contentType.contains("charset=")) {
            charset = Charset.forName(contentType.substring(contentType.indexOf("charset=") + 8).trim());
        }
        headers.put(HeaderNames.CONTENT_TYPE, contentType);
    }
1070213
public function setContentType($contentType) {
    $this->contentType = $contentType;
    
    $ct = $this->contentType;
    if (isset($this->charset))
      $ct .= '; charset='.$this->charset;

    $this->setMeta('content-type',$ct, TRUE);
  }
920481
public function setContenttype($contenttype)
    {
        if (is_string($contenttype)) {
            $contenttype = $this->app['storage']->getContenttype($contenttype);
        }

        $this->contenttype = $contenttype;
    }