/[suikacvs]/markup/html/whatpm/Whatpm/CacheManifest.pm
Suika

Contents of /markup/html/whatpm/Whatpm/CacheManifest.pm

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.8 - (hide annotations) (download)
Sun Aug 31 13:27:33 2008 UTC (18 years, 2 months ago) by wakaba
Branch: MAIN
CVS Tags: HEAD
Changes since 1.7: +55 -8 lines
++ whatpm/Whatpm/ChangeLog	31 Aug 2008 13:23:51 -0000
	* CacheManifest.pm: Support for extensibility (HTML5 revision 2051).

2008-08-31  Wakaba  <wakaba@suika.fam.cx>

1 wakaba 1.1 package Whatpm::CacheManifest;
2     use strict;
3 wakaba 1.8 our $VERSION=do{my @r=(q$Revision: 1.7 $=~/\d+/g);sprintf "%d."."%02d" x $#r,@r};
4 wakaba 1.1 require Message::URI::URIReference;
5    
6 wakaba 1.7 sub parse_byte_string ($$$$;$$) {
7 wakaba 1.1 require Encode;
8     my $s = Encode::decode ('utf-8', $_[1]);
9     return $_[0]->_parse (\$s, $_[2], $_[3], $_[4] || sub {
10     my %err = @_;
11     warn $err{type}, "\n";
12 wakaba 1.7 }, $_[5]);
13 wakaba 1.1 } # parse_byte_string
14    
15 wakaba 1.7 sub parse_char_string ($$$$;$$) {
16 wakaba 1.1 return $_[0]->_parse (\($_[1]), $_[2], $_[3], $_[4] || sub {
17     my %err = @_;
18     warn $err{type}, "\n";
19 wakaba 1.7 }, $_[5]);
20 wakaba 1.1 } # parse_char_string
21    
22 wakaba 1.7 my $default_error_levels = {
23     must => 'm',
24     info => 'i',
25     };
26    
27     sub _parse ($$$$$$) {
28     #my (undef, $input, $manifest_uri, $base_uri, $onerror, $levels) = @_;
29 wakaba 1.1
30     ## NOTE: A manifest MUST be labeled as text/cache-manifest. (This should
31     ## be checked in upper-level).
32     ## NOTE: No "MUST" for being UTF-8.
33     ## NOTE: A |text/cache-manifest| MUST be a cache manifest.
34     ## NOTE: Newlines MUST be CR/CRLF/LF. (We don't and can't check this.)
35    
36 wakaba 1.2 ## ISSUE: In RFC 2046: "The specification for any future subtypes of "text" must specify whether or not they will also utilize a "charset" parameter"
37    
38 wakaba 1.1 my $m_uri = Message::DOM::DOMImplementation->create_uri_reference ($_[2]);
39     my $m_scheme = $m_uri->uri_scheme;
40    
41     my $onerror = $_[4];
42 wakaba 1.7 my $levels = $_[5] || $default_error_levels;
43    
44 wakaba 1.1 my $line_number = 1;
45    
46 wakaba 1.4 ## Same origin with the manifest's URI
47     my $same_origin = sub {
48     ## NOTE: Step numbers in this function corresponds to those in the
49     ## algorithm for determining the origin of a URI specified in HTML5.
50 wakaba 1.1
51 wakaba 1.4 ## 1. and 2.
52 wakaba 1.1