Merge branch 'master' of https://github.com/EiffelWebFramework/EWF
This commit is contained in:
@@ -63,6 +63,7 @@ feature {NONE} -- Initialization
|
|||||||
t: STRING_8
|
t: STRING_8
|
||||||
i,n: INTEGER
|
i,n: INTEGER
|
||||||
p: INTEGER
|
p: INTEGER
|
||||||
|
cl: CELL [INTEGER]
|
||||||
do
|
do
|
||||||
-- Ignore starting space (should not be any)
|
-- Ignore starting space (should not be any)
|
||||||
from
|
from
|
||||||
@@ -79,18 +80,13 @@ feature {NONE} -- Initialization
|
|||||||
if p > 0 then
|
if p > 0 then
|
||||||
t := s.substring (i, p - 1)
|
t := s.substring (i, p - 1)
|
||||||
from
|
from
|
||||||
|
create cl.put (p)
|
||||||
|
i := p + 1
|
||||||
until
|
until
|
||||||
i >= n
|
i >= n
|
||||||
loop
|
loop
|
||||||
i := p + 1
|
add_parameter_from_string (s, i, cl)
|
||||||
p := s.index_of (';', i)
|
i := cl.item
|
||||||
if p = 0 then
|
|
||||||
add_parameter_from_string (s, i, n)
|
|
||||||
i := n
|
|
||||||
else
|
|
||||||
add_parameter_from_string (s, i, p - 1)
|
|
||||||
i := p + 1
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
t := s.substring (i, n)
|
t := s.substring (i, n)
|
||||||
@@ -271,45 +267,80 @@ feature -- Element change
|
|||||||
|
|
||||||
feature {NONE} -- Implementation
|
feature {NONE} -- Implementation
|
||||||
|
|
||||||
add_parameter_from_string (s: READABLE_STRING_8; start_index, end_index: INTEGER)
|
add_parameter_from_string (s: READABLE_STRING_8; start_index: INTEGER; out_end_index: CELL [INTEGER])
|
||||||
-- Add parameter from string " attribute=value "
|
-- Add parameter from string " attribute=value "
|
||||||
|
-- and put in `out_end_index' the index after found parameter.
|
||||||
local
|
local
|
||||||
|
n: INTEGER
|
||||||
pn,pv: STRING_8
|
pn,pv: STRING_8
|
||||||
i: INTEGER
|
i: INTEGER
|
||||||
p: INTEGER
|
p, q: INTEGER
|
||||||
err: BOOLEAN
|
err: BOOLEAN
|
||||||
do
|
do
|
||||||
-- Skip spaces
|
n := s.count
|
||||||
|
-- Skip spaces
|
||||||
from
|
from
|
||||||
i := start_index
|
i := start_index
|
||||||
until
|
until
|
||||||
i > end_index or not s[i].is_space
|
i > n or not s[i].is_space
|
||||||
loop
|
loop
|
||||||
i := i + 1
|
i := i + 1
|
||||||
end
|
end
|
||||||
if i < end_index then
|
if s[i] = ';' then
|
||||||
|
-- empty parameter
|
||||||
|
out_end_index.replace (i + 1)
|
||||||
|
elseif i < n then
|
||||||
p := s.index_of ('=', i)
|
p := s.index_of ('=', i)
|
||||||
if p > 0 and p < end_index then
|
if p > 0 then
|
||||||
pn := s.substring (i, p - 1)
|
pn := s.substring (i, p - 1)
|
||||||
pv := s.substring (p + 1, end_index)
|
if p >= n then
|
||||||
pv.right_adjust
|
pv := ""
|
||||||
if pv.count > 0 and pv [1] = '%"' then
|
out_end_index.replace (n + 1)
|
||||||
if pv [pv.count] = '%"' then
|
else
|
||||||
pv := pv.substring (2, pv.count - 1)
|
if s[p+1] = '%"' then
|
||||||
|
q := s.index_of ('%"', p + 2)
|
||||||
|
if q > 0 then
|
||||||
|
pv := s.substring (p + 2, q - 1)
|
||||||
|
from
|
||||||
|
i := q + 1
|
||||||
|
until
|
||||||
|
i > n or not s[i].is_space
|
||||||
|
loop
|
||||||
|
i := i + 1
|
||||||
|
end
|
||||||
|
if s[i] = ';' then
|
||||||
|
i := i + 1
|
||||||
|
end
|
||||||
|
out_end_index.replace (i)
|
||||||
|
else
|
||||||
|
err := True
|
||||||
|
pv := ""
|
||||||
|
-- missing closing double quote.
|
||||||
|
end
|
||||||
else
|
else
|
||||||
err := True
|
q := s.index_of (';', p + 1)
|
||||||
-- missing closing double quote.
|
if q = 0 then
|
||||||
|
q := n + 1
|
||||||
|
end
|
||||||
|
pv := s.substring (p + 1, q - 1)
|
||||||
|
out_end_index.replace (q + 1)
|
||||||
|
end
|
||||||
|
pv.right_adjust
|
||||||
|
if not err then
|
||||||
|
add_parameter (pn, pv)
|
||||||
end
|
end
|
||||||
end
|
|
||||||
if not err then
|
|
||||||
add_parameter (pn, pv)
|
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
-- expecting: attribute "=" value
|
-- expecting: attribute "=" value
|
||||||
err := True
|
err := True
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
if err then
|
||||||
|
out_end_index.replace (n + 1)
|
||||||
|
end
|
||||||
has_error := has_error or err
|
has_error := has_error or err
|
||||||
|
ensure
|
||||||
|
entry_processed: out_end_index.item > start_index
|
||||||
end
|
end
|
||||||
|
|
||||||
feature {NONE} -- Internal
|
feature {NONE} -- Internal
|
||||||
|
|||||||
@@ -12,9 +12,16 @@ inherit
|
|||||||
|
|
||||||
feature -- Content type
|
feature -- Content type
|
||||||
|
|
||||||
test_http_content_type
|
|
||||||
|
test_http_content_types_with_params
|
||||||
local
|
local
|
||||||
ct: HTTP_CONTENT_TYPE
|
do
|
||||||
|
test_content_type_with_params ("text/plain; param1=%"something;foo=bar%"; param2=%"another-thing%"",
|
||||||
|
"text", "plain", <<["param1", "something;foo=bar"], ["param2", "another-thing"]>>
|
||||||
|
)
|
||||||
|
end
|
||||||
|
|
||||||
|
test_http_content_type
|
||||||
do
|
do
|
||||||
test_content_type ("application/atom+xml", "application", "atom+xml") -- Atom feeds
|
test_content_type ("application/atom+xml", "application", "atom+xml") -- Atom feeds
|
||||||
test_content_type ("application/ecmascript", "application", "ecmascript") -- ECMAScript/JavaScript; Defined in RFC 4329 (equivalent to application/javascript but with stricter processing rules)
|
test_content_type ("application/ecmascript", "application", "ecmascript") -- ECMAScript/JavaScript; Defined in RFC 4329 (equivalent to application/javascript but with stricter processing rules)
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
<?xml version="1.0" encoding="ISO-8859-1"?>
|
<?xml version="1.0" encoding="ISO-8859-1"?>
|
||||||
<system xmlns="http://www.eiffel.com/developers/xml/configuration-1-10-0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.eiffel.com/developers/xml/configuration-1-10-0 http://www.eiffel.com/developers/xml/configuration-1-10-0.xsd" name="tests" uuid="0582ACC2-11D8-4FE5-888D-61837BA8F43E">
|
<system xmlns="http://www.eiffel.com/developers/xml/configuration-1-11-0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.eiffel.com/developers/xml/configuration-1-11-0 http://www.eiffel.com/developers/xml/configuration-1-11-0.xsd" name="tests" uuid="0582ACC2-11D8-4FE5-888D-61837BA8F43E">
|
||||||
<target name="tests">
|
<target name="tests">
|
||||||
<root class="AUTOTEST" feature="make"/>
|
<root class="AUTOTEST" feature="make"/>
|
||||||
<file_rule>
|
<file_rule>
|
||||||
@@ -7,11 +7,16 @@
|
|||||||
<exclude>/EIFGENs$</exclude>
|
<exclude>/EIFGENs$</exclude>
|
||||||
<exclude>/.svn$</exclude>
|
<exclude>/.svn$</exclude>
|
||||||
</file_rule>
|
</file_rule>
|
||||||
<option warning="true" full_class_checking="true" is_attached_by_default="true" void_safety="all" syntax="standard">
|
<option warning="true" full_class_checking="true" is_attached_by_default="true" void_safety="transitional" syntax="standard">
|
||||||
|
<assertions precondition="true" postcondition="true" check="true"/>
|
||||||
</option>
|
</option>
|
||||||
<setting name="concurrency" value="none"/>
|
<setting name="concurrency" value="none"/>
|
||||||
<library name="base" location="$ISE_LIBRARY\library\base\base-safe.ecf"/>
|
<library name="base" location="$ISE_LIBRARY\library\base\base-safe.ecf"/>
|
||||||
<library name="http" location="..\http-safe.ecf" readonly="false"/>
|
<library name="http" location="..\http-safe.ecf" readonly="false">
|
||||||
|
<option>
|
||||||
|
<assertions precondition="true" postcondition="true" check="true"/>
|
||||||
|
</option>
|
||||||
|
</library>
|
||||||
<library name="testing" location="$ISE_LIBRARY\library\testing\testing-safe.ecf"/>
|
<library name="testing" location="$ISE_LIBRARY\library\testing\testing-safe.ecf"/>
|
||||||
<tests name="src" location=".\" recursive="true"/>
|
<tests name="src" location=".\" recursive="true"/>
|
||||||
</target>
|
</target>
|
||||||
|
|||||||
Reference in New Issue
Block a user