Initial commit.

This commit is contained in:
2026-03-10 21:25:26 +08:00
commit 78739bf725
3089 changed files with 472990 additions and 0 deletions

63
lib/perl5/Selima/XHTML.pm Normal file
View File

@@ -0,0 +1,63 @@
# Selima Website Content Management System
# XHTML.pm: The subroutine to return application/xhtml+xml on supported browsers and text/html othersise.
# Copyright (c) 2004-2018 imacat.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# Author: imacat <imacat@mail.imacat.idv.tw>
# First written: 2004-12-26
package Selima::XHTML;
use 5.008;
use strict;
use warnings;
use base qw(Exporter);
use vars qw(@EXPORT @EXPORT_OK);
BEGIN {
@EXPORT = qw(xhtml_content_type);
@EXPORT_OK = @EXPORT;
# Prototype declaration
sub xhtml_content_type();
}
use Selima::DataVars qw($IS_MODPERL :env);
# xhtml_content_type: Check whether application/xhtml+xml or text/html
# should be sent to the client
sub xhtml_content_type() {
local ($_, %_);
my ($r, $acpt, $ua);
# Obtain the required parameters
if ($IS_MODPERL) {
$r = $IS_MP2? Apache2::RequestUtil->request:
Apache->request;
$acpt = $r->headers_in->get("Accept");
$ua = $r->headers_in->get("User-Agent");
} else {
$acpt = exists $ENV{"HTTP_ACCEPT"}? $ENV{"HTTP_ACCEPT"}: undef;
$ua = exists $ENV{"HTTP_USER_AGENT"}? $ENV{"HTTP_USER_AGENT"}: undef;
}
# Browsers that claim to support application/xhtml+xml explicitly
return "application/xhtml+xml"
if defined $acpt && $acpt =~ /\bapplication\/xhtml\+xml\b/;
# Browsers that are known to support application/xhtml+xml
return "application/xhtml+xml"
if defined $ua && $ua =~ /^W3C_Validator\//;
# Else, we assume that application/xhtml+xml is not supported
return "text/html";
}
return 1;