Skip to content

Commit 24f5f88

Browse files
committed
Handle #547 and #545: records accepted in smart poster
Signed-off-by: Zoltan Kis <[email protected]>
1 parent f385c03 commit 24f5f88

File tree

1 file changed

+93
-61
lines changed

1 file changed

+93
-61
lines changed

index.html

Lines changed: 93 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -2530,18 +2530,25 @@ <h3><dfn>Writing content</dfn></h3>
25302530
throw {{TypeError}} and abort these steps.
25312531
</li>
25322532
<li>
2533-
Return `true`;
2533+
If |context| is `"smart-poster"`, move the <a>URI record</a> to
2534+
the beginning of |records|.
25342535
</li>
25352536
</ol>
2537+
<p class="note">
2538+
Web NFC currently allows writing <a>external type</a> and
2539+
<a>local type</a> records in <a>smart poster</a>.
2540+
Also, <a>empty records</a> are allowed.
2541+
Applications MAY ignore any extra records inside
2542+
the <a>smart poster</a>.
2543+
</p>
25362544
<p class="note">
25372545
Icon record media types could be limited to `"image/"` or `"video/"`,
25382546
but the [[NDEF-SMARTPOSTER]] specification does actually allow other
25392547
media type records in a <a>smart poster</a>, which can be treated in
25402548
an application-specific manner, for instance a vCard contact card
25412549
using one of its associated
25422550
<a href="https://www.iana.org/assignments/media-types/media-types.xhtml">
2543-
MIME types</a>. Applications MAY ignore any extra records inside
2544-
the <a>smart poster</a>.
2551+
MIME types</a>.
25452552
</p>
25462553
</div>
25472554
</section>
@@ -2574,89 +2581,81 @@ <h3><dfn>Writing content</dfn></h3>
25742581
</ul>
25752582
</li>
25762583
<li>
2577-
If |record|'s <a>recordType</a> starts with a colon `U+003A` (`:`):
2578-
<ul>
2579-
<li>
2580-
If |record| is not a payload to another <a>NDEF record</a>
2581-
or if |context| is `"smart-poster"`,
2582-
reject |promise| with a {{TypeError}} and abort these steps.
2583-
</li>
2584-
<li>
2585-
If running the <a>validate local type</a> steps on |record|'s
2586-
<a>recordType</a> returns `false`, reject |promise| with a
2587-
{{TypeError}} and abort these steps.
2588-
</li>
2589-
<li>
2590-
Return the result of running
2591-
<a>map local type to NDEF</a> given |record| and |ndef|.
2592-
</li>
2593-
</ul>
2594-
<li>
2595-
Switching on |record|'s <a>recordType</a>, invoke one of the
2596-
following algorithms and return the result.
2597-
If the algorithm throws an exception |e|, reject |promise| with |e|
2584+
Switching on |record|'s <a>recordType</a>, invoke the algorithm
2585+
specified below with |record|, |ndef| and |context| and return the
2586+
result. If an exception |e| is thrown, reject |promise| with |e|
25982587
and abort these steps.
25992588
<dl>
26002589
<dt>"`empty`"</dt>
26012590
<ul>
26022591
<li>
2603-
If |context| is `"smart-poster"`,
2604-
[= exception/throw =] a {{TypeError}} and abort these steps.
2605-
</li>
2606-
<li>
2607-
Return <a>map empty record to NDEF</a> given |record| and |ndef|.
2592+
<a>map empty record to NDEF</a>.
26082593
</li>
26092594
</ul>
26102595
<dt>"`text`"</dt>
26112596
<ul>
26122597
<li>
2613-
Return <a>map text to NDEF</a> given |record| and |ndef|.
2598+
<a>map text to NDEF</a>.
26142599
</li>
26152600
</ul>
26162601
<dt>"`url`"</dt>
26172602
<ul>
26182603
<li>
2619-
Return <a>map a URL to NDEF</a> given |record| and |ndef|.
2604+
<a>map a URL to NDEF</a>.
26202605
</li>
26212606
</ul>
26222607
<dt>"`mime`"</dt>
26232608
<ul>
26242609
<li>
2625-
Return <a>map binary data to NDEF</a> given |record| and |ndef|.
2610+
<a>map binary data to NDEF</a>.
26262611
</li>
26272612
</ul>
26282613
<dt>"`smart-poster`"</dt>
26292614
<ul>
26302615
<li>
2631-
Return <a>map smart poster to NDEF</a> given |record|, |ndef|
2632-
and |context|.
2616+
<a>map smart poster to NDEF</a>.
26332617
</li>
26342618
</ul>
26352619
<dt>"`absolute-url`"</dt>
26362620
<ul>
26372621
<li>
2638-
If |context| is `"smart-poster"`,
2639-
[= exception/throw =] a {{TypeError}} and abort these steps.
2640-
</li>
2641-
<li>
2642-
Return <a>map absolute-URL to NDEF</a> given |record| and
2643-
|ndef|.
2622+
<a>map absolute-URL to NDEF</a>.
26442623
</li>
26452624
</ul>
26462625
</dl>
26472626
</li>
26482627
<li>
2649-
If running <a>validate external type</a> on |record|'s
2650-
<a>recordType</a> returns `true`,
2651-
<ol>
2628+
If |record|'s <a>recordType</a> starts with a colon `U+003A` (`:`):
2629+
<ul>
26522630
<li>
2653-
If |context| is `"smart-poster"`,
2654-
[= exception/throw =] a {{TypeError}} and abort these steps.
2631+
If |record| is not a payload to another <a>NDEF record</a>
2632+
and if |context| is not `"smart-poster"`,
2633+
reject |promise| with a {{TypeError}} and abort these steps.
26552634
</li>
26562635
<li>
2657-
Return <a>map external data to NDEF</a> given |record| and |ndef|.
2636+
If running the <a>validate local type</a> steps on |record|'s
2637+
<a>recordType</a> returns `false`, reject |promise| with a
2638+
{{TypeError}} and abort these steps.
26582639
</li>
2659-
</ol>
2640+
<!--
2641+
TODO: include clauses to fix
2642+
https://github.com/w3c/web-nfc/issues/546, i.e.
2643+
check SP size and action records payload size.
2644+
-->
2645+
<li>
2646+
Return the result of running
2647+
<a>map local type to NDEF</a> given |record|, |ndef| and
2648+
|context|. If that throws an exception |e|, reject |promise|
2649+
with |e| and abort these steps.
2650+
</li>
2651+
</ul>
2652+
</li>
2653+
<li>
2654+
If running <a>validate external type</a> on |record|'s
2655+
<a>recordType</a> returns `true`,
2656+
return <a>map external data to NDEF</a> given |record|, |ndef| and
2657+
|context|. If that throws an exception |e|, reject |promise|
2658+
with |e| and abort these steps.
26602659
</li>
26612660
<li>
26622661
Otherwise, [= exception/throw =] a {{TypeError}} and abort
@@ -2769,8 +2768,14 @@ <h3><dfn>Writing content</dfn></h3>
27692768
<section><h3>Mapping empty record to NDEF</h3>
27702769
<div>
27712770
To <dfn>map empty record to NDEF</dfn> given a |record:NDEFRecordInit|
2772-
and |ndef|, run these steps:
2771+
|ndef| and |context:string|, run these steps:
27732772
<ol class=algorithm data-link-for="NDEFRecordInit">
2773+
<!--
2774+
<li>
2775+
If |context| is `"smart-poster"`,
2776+
[= exception/throw =] a {{TypeError}} and abort these steps.
2777+
</li>
2778+
-->
27742779
<li>
27752780
If |record|'s <a>mediaType</a> is not `undefined`,
27762781
[= exception/throw =] a {{TypeError}} and abort these steps.
@@ -2799,8 +2804,8 @@ <h3><dfn>Writing content</dfn></h3>
27992804

28002805
<section><h3>Mapping string to NDEF</h3>
28012806
<div>
2802-
To <dfn>map text to NDEF</dfn> given a |record:NDEFRecordInit| and
2803-
|ndef|, run these steps:
2807+
To <dfn>map text to NDEF</dfn> given a |record:NDEFRecordInit|, |ndef|
2808+
and |context:string|, run these steps:
28042809
<p class="note">
28052810
This is useful when clients specifically want to write text in a
28062811
[=well-known type record=].
@@ -2953,8 +2958,8 @@ <h3><dfn>Writing content</dfn></h3>
29532958

29542959
<section><h3>Mapping URL to NDEF</h3>
29552960
<div>
2956-
To <dfn>map a URL to NDEF</dfn> given a |record:NDEFRecordInit| and
2957-
|ndef|, run these steps:
2961+
To <dfn>map a URL to NDEF</dfn> given a |record:NDEFRecordInit|, |ndef|
2962+
and |context:string|, run these steps:
29582963
<ol class=algorithm data-link-for="NDEFRecordInit">
29592964
<li>
29602965
If |record|'s <a>mediaType</a> is not `undefined`,
@@ -3039,8 +3044,8 @@ <h3><dfn>Writing content</dfn></h3>
30393044

30403045
<section><h3>Mapping binary data to NDEF</h3>
30413046
<div>
3042-
To <dfn>map binary data to NDEF</dfn> given a |record:NDEFRecordInit|
3043-
and |ndef|, run these steps:
3047+
To <dfn>map binary data to NDEF</dfn> given a |record:NDEFRecordInit|,
3048+
|ndef| and |context:string|, run these steps:
30443049
<ol class=algorithm data-link-for="NDEFRecord">
30453050
<li>
30463051
If the type of a |record|'s <a>data</a> is not
@@ -3097,9 +3102,15 @@ <h3><dfn>Writing content</dfn></h3>
30973102

30983103
<section><h3>Mapping external data to NDEF</h3>
30993104
<div>
3100-
To <dfn>map external data to NDEF</dfn> given a |record:NDEFRecordInit|
3101-
and |ndef|, run these steps:
3105+
To <dfn>map external data to NDEF</dfn> given a |record:NDEFRecordInit|,
3106+
|ndef| and |context:string|, run these steps:
31023107
<ol class=algorithm data-link-for="NDEFRecordInit">
3108+
<!--
3109+
<li>
3110+
If |context| is `"smart-poster"`,
3111+
[= exception/throw =] a {{TypeError}} and abort these steps.
3112+
</li>
3113+
-->
31033114
<li>
31043115
If |record|'s <a>mediaType</a> is not `undefined`,
31053116
[= exception/throw =] a {{TypeError}} and abort these steps.
@@ -3161,8 +3172,8 @@ <h3><dfn>Writing content</dfn></h3>
31613172

31623173
<section><h3>Mapping local type to NDEF</h3>
31633174
<div>
3164-
To <dfn>map local type to NDEF</dfn> given a |record:NDEFRecordInit| and
3165-
|ndef|, run these steps:
3175+
To <dfn>map local type to NDEF</dfn> given a |record:NDEFRecordInit|,
3176+
|ndef| and |context:string|, run these steps:
31663177
<ol class=algorithm data-link-for="NDEFRecordInit">
31673178
<li>
31683179
If |record|'s <a>mediaType</a> is not `undefined`,
@@ -3221,6 +3232,10 @@ <h3><dfn>Writing content</dfn></h3>
32213232
</li>
32223233
</ol>
32233234
</li>
3235+
<!--
3236+
TODO: clauses to fix https://github.com/w3c/web-nfc/issues/546
3237+
check SP size and action records payload size.
3238+
-->
32243239
<li>
32253240
Return |ndef|.
32263241
</li>
@@ -3231,7 +3246,7 @@ <h3><dfn>Writing content</dfn></h3>
32313246
<section><h3>Mapping smart poster to NDEF</h3>
32323247
<div>
32333248
To <dfn>map smart poster to NDEF</dfn>, given a |record:NDEFRecordInit|
3234-
and |ndef|, run these steps:
3249+
|ndef| and |context:string|, run these steps:
32353250
<ol class=algorithm data-link-for="NDEFRecordInit">
32363251
<li>
32373252
If |record|'s <a>mediaType</a> is not `undefined`,
@@ -3268,8 +3283,16 @@ <h3><dfn>Writing content</dfn></h3>
32683283
<section><h3>Mapping absolute-URL to NDEF</h3>
32693284
<div>
32703285
To <dfn>map absolute-URL to NDEF</dfn> given a |record:NDEFRecordInit|
3271-
and |ndef|, run these steps:
3286+
|ndef| and |context:string|, run these steps:
32723287
<ol class=algorithm data-link-for="NDEFRecord">
3288+
<li>
3289+
If |context| is `"smart-poster"`,
3290+
[= exception/throw =] a {{TypeError}} and abort these steps.
3291+
<p class="note">
3292+
The [[NDEF-SMARTPOSTER]] specification allows only one URL in
3293+
a <a>smart poster</a> and that MUST be a single <a>URI record</a>.
3294+
</p>
3295+
</li>
32733296
<li>
32743297
If |record|'s <a>mediaType</a> is not `undefined`,
32753298
[= exception/throw =] a {{TypeError}} and abort these steps.
@@ -3708,11 +3731,20 @@ <h3>Parsing content</h3>
37083731
</li>
37093732
<li>
37103733
If |context| is `"smart-poster"` and |records| contain
3711-
[=absolute-URL records=], remove them rom |records|.
3734+
[=absolute-URL records=], remove them from |records|.
3735+
<p class="note">
3736+
In other words, remove [=absolute-URL records=] from <a>smart poster</a>,
3737+
as required by the [[NDEF-SMARTPOSTER]] specification.
3738+
</p>
37123739
</li>
37133740
<li>
37143741
If any record in |records| is a <a>smart poster</a>, then remove
37153742
all <a>URI records</a> and [=absolute-URL records=] from |records|.
3743+
<p class="note">
3744+
In other words, remove [=absolute-URL records=] and <a>URI records</a>
3745+
from <a>NDEF messages</a> that contain a <a>smart poster</a> record,
3746+
as required by the [[NDEF-SMARTPOSTER]] specification.
3747+
</p>
37163748
</li>
37173749
<li>
37183750
Otherwise return `true`.

0 commit comments

Comments
 (0)