Skip to content

Commit

Permalink
docs(guide): Security french translation (angular#78)
Browse files Browse the repository at this point in the history
  • Loading branch information
RudyWeber authored and Wassim Chegham committed Sep 14, 2016
1 parent ac78250 commit d3429e2
Show file tree
Hide file tree
Showing 5 changed files with 201 additions and 191 deletions.
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
<!--#docregion -->
<h3>Bypass Security Component</h3>
<h3>Contourner la sécurité des composants</h3>

<!--#docregion dangerous-url -->
<h4>A untrusted URL:</h4>
<h4>Une URL douteuse :</h4>
<p><a class="e2e-dangerous-url" [href]="dangerousUrl">Click me</a></p>
<h4>A trusted URL:</h4>
<h4>Une URL de confiance :</h4>
<p><a class="e2e-trusted-url" [href]="trustedUrl">Click me</a></p>
<!--#enddocregion dangerous-url -->

<!--#docregion iframe-videoid -->
<h4>Resource URL:</h4>
<p><label>Showing: <input (input)="updateVideoUrl($event.target.value)"></label></p>
<p>Trusted:</p>
<iframe class="e2e-iframe-trusted-src" width="640" height="390" [src]="videoUrl"></iframe>
<p>Untrusted:</p>
<iframe class="e2e-iframe-untrusted-src" width="640" height="390" [src]="dangerousVideoUrl"></iframe>
<h4>URL de ressources :</h4>
<p><label>Affichage de : <input (input)="updateVideoUrl($event.target.value)"></label></p>
<p>OK :</p>
<iframe class="e2e-iframe-trusted-src" width="640" height="390" [src]="urlDeVideo"></iframe>
<p>Douteux :</p>
<iframe class="e2e-iframe-untrusted-src" width="640" height="390" [src]="urlDangereuseDeVideo"></iframe>
<!--#enddocregion iframe-videoid -->

<!--#enddocregion -->
33 changes: 17 additions & 16 deletions public/docs/_examples/security/ts/app/bypass-security.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,31 +8,32 @@ import { DomSanitizationService, SafeResourceUrl, SafeUrl } from '@angular/platf
templateUrl: 'app/bypass-security.component.html',
})
export class BypassSecurityComponent {
dangerousUrl: string;
trustedUrl: SafeUrl;
dangerousVideoUrl: string;
videoUrl: SafeResourceUrl;
urlDangereuse: string;
UrlDeConfiance: SafeUrl;
urlDangereuseDeVideo: string;
urlDeVideo: SafeResourceUrl;

// #docregion trust-url
constructor(private sanitizer: DomSanitizationService) {
// javascript: URLs are dangerous if attacker controlled.
// Angular sanitizes them in data binding, but we can
// explicitly tell Angular to trust this value:
this.dangerousUrl = 'javascript:alert("Hi there")';
this.trustedUrl = sanitizer.bypassSecurityTrustUrl(this.dangerousUrl);
// javascript : les URLs sont dangeureuses si elles sont contrôllées
// par un attaquant.
// Angular les sécurise lorsque les données sont liées mais il est possible
// de dire explicitement à Angular de faire confiance à ces données :
this.urlDangereuse = 'javascript:alert("Hi there")';
this.UrlDeConfiance = sanitizer.bypassSecurityTrustUrl(this.urlDangereuse);
// #enddocregion trust-url
this.updateVideoUrl('PUBnlbjZFAI');
}

// #docregion trust-video-url
updateVideoUrl(id: string) {
// Appending an ID to a YouTube URL is safe.
// Always make sure to construct SafeValue objects as
// close as possible to the input data, so
// that it's easier to check if the value is safe.
this.dangerousVideoUrl = 'https://www.youtube.com/embed/' + id;
this.videoUrl =
this.sanitizer.bypassSecurityTrustResourceUrl(this.dangerousVideoUrl);
// Ajouter un ID à une URL YouTuve n'est pas risqué.
// Veillez à toujours construire des objets SafeValue aussi fidèles
// que possible aux données entrées afin de faciliter
// leur vérification.
this.urlDangereuseDeVideo = 'https://www.youtube.com/embed/' + id;
this.urlDeVideo =
this.sanitizer.bypassSecurityTrustResourceUrl(this.urlDangereuseDeVideo);
}
// #enddocregion trust-video-url
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<!-- #docregion -->
<h3>Binding innerHTML</h3>
<p>Bound value:</p>
<h3>Lier innerHTML</h3>
<p>Valeur liée :</p>
<p class="e2e-inner-html-interpolated">{{htmlSnippet}}</p>
<p>Result of binding to innerHTML:</p>
<p>Resultat de la liaison à innerHTML :</p>
<p class="e2e-inner-html-bound" [innerHTML]="htmlSnippet"></p>
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@ import { Component } from '@angular/core';
})
// #docregion inner-html-controller
export class InnerHtmlBindingComponent {
// E.g. a user/attacker controlled value from a URL.
// I.e. Des données contrôlées par un utilisateur / attaquant.
htmlSnippet = 'Template <script>alert("0wned")</script> <b>Syntax</b>';
}
Loading

0 comments on commit d3429e2

Please sign in to comment.