Electromagnetic-field quantization in absorbing confined systems