Skip to content

Commit f321970

Browse files
jeffhandleyCopilot
andauthored
Add notes about untrusted data in System.Speech API docs (#12058)
* Add notes about untrusted data in System.Speech API docs * Add back specific verbiage about URIs and DLLs Co-authored-by: Copilot <[email protected]> * Fix indentation of note * Add back the blank line between paragraphs * Improve wording to 'instance of this type' --------- Co-authored-by: Copilot <[email protected]>
1 parent d7a3c99 commit f321970

File tree

9 files changed

+49
-10
lines changed

9 files changed

+49
-10
lines changed
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
> [!IMPORTANT]
2-
> Using an instance of this object with untrusted data is a security risk. Use this object only with trusted data. For more information, see [Validate All Inputs](https://top10proactive.owasp.org/archive/2024/the-top-10/c3-validate-input-and-handle-exceptions/).
2+
> Using an instance of this type with untrusted data is a security risk. Use this object only with trusted data. For more information, see [Validate All Inputs](https://top10proactive.owasp.org/archive/2024/the-top-10/c3-validate-input-and-handle-exceptions/).

xml/System.Speech.Recognition.SrgsGrammar/SrgsDocument.xml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -857,6 +857,8 @@ public void WorldSoccerWinners ()
857857
## Remarks
858858
<xref:System.Speech.Recognition.SrgsGrammar.SrgsDocument.XmlBase%2A> property gets a value that is used to resolve relative URIs in a <xref:System.Speech.Recognition.SrgsGrammar.SrgsDocument> object. Suppose the value for <xref:System.Speech.Recognition.SrgsGrammar.SrgsDocument.XmlBase%2A> is `http://www.contoso.com/` and the <xref:System.Speech.Recognition.SrgsGrammar.SrgsDocument> contains a relative rule reference to another document, for example `SrgsRuleRef("ExternalGrammar.grxml")`. This creates the following absolute path to the external document: `http://www.contoso.com/ExternalGrammar.grxml`.
859859
860+
[!INCLUDE [untrusted-data-instance-note](~/includes/untrusted-data-instance-note.md)]
861+
860862
]]></format>
861863
</remarks>
862864
</Docs>

xml/System.Speech.Recognition.SrgsGrammar/SrgsRuleRef.xml

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,8 @@
5252
5353
This class represents the `ruleref` element as defined in the World Wide Web Consortium (W3C) [Speech Recognition Grammar Specification (SRGS) Version 1.0](https://go.microsoft.com/fwlink/?LinkId=201761). For information about the SRGS `ruleref` element and details about its support by System.Speech, see [ruleref Element](https://msdn.microsoft.com/library/56eb0031-4908-4788-83ab-7c5e19aa4ac0).
5454
55+
[!INCLUDE [untrusted-data-instance-note](~/includes/untrusted-data-instance-note.md)]
56+
5557
]]></format>
5658
</remarks>
5759
<related type="Article" href="https://learn.microsoft.com/previous-versions/office/developer/speech-technologies/hh361680(v%3doffice.14)">Create Grammars Using SrgsGrammar</related>
@@ -211,7 +213,7 @@ public void WorldSoccerWinners ()
211213
212214
- <xref:System.Speech.Recognition.SrgsGrammar.SrgsRuleRef.%23ctor%2A>
213215
214-
216+
[!INCLUDE [untrusted-data-instance-note](~/includes/untrusted-data-instance-note.md)]
215217
216218
## Examples
217219
The following example creates a grammar for an application that returns information about bus shuttle service. The first method, `GrammarUrlForRoute`, takes a string that specifies a route and appends it to a string specifying the location of a grammar. This specifies a particular rule in that grammar. The method returns a `Uri` for that rule.
@@ -407,6 +409,8 @@ namespace SampleRecognition
407409
408410
- <xref:System.Speech.Recognition.SrgsGrammar.SrgsRuleRef.%23ctor%2A>
409411
412+
[!INCLUDE [untrusted-data-instance-note](~/includes/untrusted-data-instance-note.md)]
413+
410414
]]></format>
411415
</remarks>
412416
<exception cref="T:System.ArgumentNullException">
@@ -497,6 +501,8 @@ namespace SampleRecognition
497501
498502
- <xref:System.Speech.Recognition.SrgsGrammar.SrgsRuleRef.%23ctor%2A>
499503
504+
[!INCLUDE [untrusted-data-instance-note](~/includes/untrusted-data-instance-note.md)]
505+
500506
]]></format>
501507
</remarks>
502508
<exception cref="T:System.ArgumentNullException">
@@ -546,6 +552,8 @@ namespace SampleRecognition
546552
547553
- <xref:System.Speech.Recognition.SrgsGrammar.SrgsRuleRef.%23ctor%2A>
548554
555+
[!INCLUDE [untrusted-data-instance-note](~/includes/untrusted-data-instance-note.md)]
556+
549557
]]></format>
550558
</remarks>
551559
<related type="Article" href="https://learn.microsoft.com/previous-versions/office/developer/speech-technologies/hh361680(v%3doffice.14)">Create Grammars Using SrgsGrammar</related>

xml/System.Speech.Recognition/Grammar.xml

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,11 @@
4545
4646
The grammar's <xref:System.Speech.Recognition.Grammar.SpeechRecognized> event is raised when input matches a path through the grammar.
4747
48+
[!INCLUDE [untrusted-data-instance-note](~/includes/untrusted-data-instance-note.md)]
49+
4850
> [!NOTE]
49-
> It is a best practice to verify the safety of any URI or DLL used to build a <xref:System.Speech.Recognition.Grammar> object.
50-
>
51+
> It is a best practice to verify the safety of any URI or DLL used to build a <xref:System.Speech.Recognition.Grammar> object, which helps prevent security vulnerabilities when loading external resources.
52+
>
5153
> Windows and the Speech platform provide security for applications constructing a <xref:System.Speech.Recognition.Grammar> instance from a DLL or from a grammar that supports scripting.
5254
>
5355
> Scripts in <xref:System.Speech.Recognition.Grammar> objects are always run as if downloaded from a web page in the `Internet Zone`. The Common Language Runtime (CLR) isolates any DLL loaded to obtain a grammar definition.
@@ -944,6 +946,7 @@ private static Grammar CreateGrammarFromFile2()
944946
945947
This constructor does not validate `baseUri`. However, the `LoadGrammar` method of a <xref:System.Speech.Recognition.SpeechRecognitionEngine> or <xref:System.Speech.Recognition.SpeechRecognizer> object throws an exception if it cannot resolve all of the rule references in the grammar description. If `baseUri` is not `null`, the `LoadGrammar` method uses the URI to resolve any rule references that it cannot otherwise resolve. If `baseUri` represents a file, then the `LoadGrammar` uses both the designated file and the file's directory when it attempts to resolve relative rule references.
946948
949+
[!INCLUDE [untrusted-data-instance-note](~/includes/untrusted-data-instance-note.md)]
947950
948951
949952
## Examples
@@ -1112,7 +1115,7 @@ private static Grammar CreateGrammarFromStream3()
11121115
11131116
This constructor does not validate `baseUri`. However, the `LoadGrammar` method of a <xref:System.Speech.Recognition.SpeechRecognitionEngine> or <xref:System.Speech.Recognition.SpeechRecognizer> object throws an exception if it cannot resolve all of the rule references in the grammar description. If `baseUri` is not `null`, the `LoadGrammar` method uses the URI to resolve any rule references that it cannot otherwise resolve. If `baseUri` represents a file, then the `LoadGrammar` method uses both the designated file and the file's directory when it attempts to resolve relative rule references.
11141117
1115-
1118+
[!INCLUDE [untrusted-data-instance-note](~/includes/untrusted-data-instance-note.md)]
11161119
11171120
## Examples
11181121
The following example creates a speech recognition grammar in an <xref:System.Speech.Recognition.SrgsGrammar.SrgsDocument> that contains a relative rule reference to the cities.xml file, and specifies a URI to use to resolve the rule reference. The content of the cities.xml file appears in the XML example that follows the C# example.
@@ -1276,6 +1279,8 @@ private static Grammar CreateSrgsDocumentGrammar3()
12761279
## Remarks
12771280
Parameters for an initialization handler may also be specified.
12781281
1282+
[!INCLUDE [untrusted-data-instance-note](~/includes/untrusted-data-instance-note.md)]
1283+
12791284
]]></format>
12801285
</remarks>
12811286
<exception cref="T:System.ArgumentException">- Any of the parameters contain an invalid value.
@@ -1329,6 +1334,8 @@ private static Grammar CreateSrgsDocumentGrammar3()
13291334
## Remarks
13301335
Parameters for an initialization handler may also be specified.
13311336
1337+
[!INCLUDE [untrusted-data-instance-note](~/includes/untrusted-data-instance-note.md)]
1338+
13321339
]]></format>
13331340
</remarks>
13341341
<exception cref="T:System.ArgumentException">- Any of the parameters contain an invalid value.

xml/System.Speech.Synthesis.TtsEngine/ITtsEngineSite.xml

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,14 @@
179179
<param name="mediaType">The media type of the resource.</param>
180180
<summary>Loads the resource at the specified URI.</summary>
181181
<returns>To be added.</returns>
182-
<remarks>To be added.</remarks>
182+
<remarks>
183+
<format type="text/markdown"><![CDATA[
184+
## Remarks
185+
186+
[!INCLUDE [untrusted-data-interface-note](~/includes/untrusted-data-interface-note.md)]
187+
188+
]]></format>
189+
</remarks>
183190
</Docs>
184191
</Member>
185192
<Member MemberName="Rate">

xml/System.Speech.Synthesis.TtsEngine/TtsEngineSsml.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@
122122
123123
The value of `mediaType` is typically a MIME specification, as the SSML specification uses MIME for media specifications.
124124
125-
125+
[!INCLUDE [untrusted-data-class-note](~/includes/untrusted-data-class-note.md)]
126126
127127
## Examples
128128
The implementation of <xref:System.Speech.Synthesis.TtsEngine.TtsEngineSsml.AddLexicon%2A> uses the <xref:System.Speech.Synthesis.TtsEngine.ITtsEngineSite> interface passed in to load a lexicon from a resource. It then stores a `System.IO.Stream` to the lexicon in a `System.Collections.Generic.Dictionary` instance, indexed by the lexicon URI.
@@ -275,7 +275,7 @@ internal struct WaveFormat {
275275
276276
This method is typically called in response to a <xref:System.Speech.Synthesis> based applications calling <xref:System.Speech.Synthesis.SpeechSynthesizer.RemoveLexicon%2A> and using the synthesizer voice implemented by the current <xref:System.Speech.Synthesis.TtsEngine.TtsEngineSsml> instance.
277277
278-
278+
[!INCLUDE [untrusted-data-class-note](~/includes/untrusted-data-class-note.md)]
279279
280280
## Examples
281281
The implementation of <xref:System.Speech.Synthesis.TtsEngine.TtsEngineSsml.RemoveLexicon%2A> uses the lexicon URI to query an instance `System.Collections.Generic.Dictionary` for the `System.IO.Stream`, closes the stream and removes the uri referring to the lexicon.

xml/System.Speech.Synthesis/FilePrompt.xml

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,8 @@
6767
## Remarks
6868
You can use this class to create an object from an existing Speech Synthesis Markup Language (SSML) file that the <xref:System.Speech.Synthesis.SpeechSynthesizer> can consume to generate speech.
6969
70-
70+
[!INCLUDE [untrusted-data-instance-note](~/includes/untrusted-data-instance-note.md)]
71+
7172
7273
## Examples
7374
The example that follows creates a <xref:System.Speech.Synthesis.FilePrompt> object that specifies a path to an SSML prompt. To speak the contents of the prompt, the example then provides the <xref:System.Speech.Synthesis.FilePrompt> object as the argument to the <xref:System.Speech.Synthesis.SpeechSynthesizer.Speak%2A> method.
@@ -150,7 +151,14 @@ namespace SampleSynthesis
150151
<param name="promptFile">The URI of the file containing the prompt content.</param>
151152
<param name="media">The media type of the file.</param>
152153
<summary>Creates a new instance of the <see cref="T:System.Speech.Synthesis.FilePrompt" /> class, and specifies the location of the file and its media type.</summary>
153-
<remarks>To be added.</remarks>
154+
<remarks>
155+
<format type="text/markdown"><![CDATA[
156+
## Remarks
157+
158+
[!INCLUDE [untrusted-data-instance-note](~/includes/untrusted-data-instance-note.md)]
159+
160+
]]></format>
161+
</remarks>
154162
</Docs>
155163
</Member>
156164
</Members>

xml/System.Speech.Synthesis/PromptBuilder.xml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -229,6 +229,8 @@ public void MySimpleText ()
229229
<remarks>
230230
<format type="text/markdown"><![CDATA[
231231
232+
[!INCLUDE [untrusted-data-class-note](~/includes/untrusted-data-class-note.md)]
233+
232234
## Examples
233235
The following example initializes a new instance of the <xref:System.Speech.Synthesis.PromptBuilder> class and then adds text to it, followed by an audio file.
234236
@@ -291,6 +293,7 @@ public void SimpleConcatenation()
291293
## Remarks
292294
The speech synthesis engine will speak the alternate text if the audio file cannot be played.
293295
296+
[!INCLUDE [untrusted-data-class-note](~/includes/untrusted-data-class-note.md)]
294297
295298
296299
## Examples
@@ -874,6 +877,7 @@ namespace SampleSynthesis
874877
875878
You can also append SSML markup as a string using <xref:System.Speech.Synthesis.PromptBuilder.AppendSsmlMarkup%2A>.
876879
880+
[!INCLUDE [untrusted-data-class-note](~/includes/untrusted-data-class-note.md)]
877881
878882
879883
## Examples

xml/System.Speech.Synthesis/SpeechSynthesizer.xml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,7 @@ namespace SampleSynthesis
164164
165165
- The value `application/vdn.ms-sapi-lex` indicates that the lexicon format is Uncompressed Lexicon, which is a Microsoft-proprietary format. This is a legacy format and we recommend that you use the PLS format described above.
166166
167+
[!INCLUDE [untrusted-data-class-note](~/includes/untrusted-data-class-note.md)]
167168
168169
169170
## Examples
@@ -766,6 +767,8 @@ namespace SampleSynthesis
766767
## Remarks
767768
See <xref:System.Speech.Synthesis.SpeechSynthesizer.AddLexicon%2A> for an example.
768769
770+
[!INCLUDE [untrusted-data-class-note](~/includes/untrusted-data-class-note.md)]
771+
769772
]]></format>
770773
</remarks>
771774
<altmember cref="M:System.Speech.Synthesis.SpeechSynthesizer.AddLexicon(System.Uri,System.String)" />

0 commit comments

Comments
 (0)