Cov txheej txheem:

Koj siv ngSanitize li cas?
Koj siv ngSanitize li cas?

Video: Koj siv ngSanitize li cas?

Video: Koj siv ngSanitize li cas?
Video: Kuv Hmoov Phem Los Koj Siab Phem-LOKY(Official MV ) 2024, Kaum ib hlis
Anonim

ng-tip 1: Yuav siv li cas ngSanitize

  1. Download angular- ua kom huv module thiab suav nrog nws hauv nplooj html.
  2. ntxiv ngSanitize nyob rau hauv lub module dependencies, var app = angular. module('myApp', [' ngSanitize ']);
  3. Ntxiv cov lus qhia uas yuav tsum tau ua hauv tus maub los: $scope. variable = 'Nyob zoo Ntiaj teb no! ';
  4. Hauv nplooj ntawv saib:

Tib neeg kuj nug, angular sanitize siv rau dab tsi?

1 Teb. Yog tias koj suav nrog lub kaum sab xis - ua kom huv script, inputs yog ua kom huv los ntawm parsing HTML rau hauv tokens. Tag nrho cov tokens muaj kev nyab xeeb (los ntawm daim ntawv teev npe dawb) yog tom qab ntawd rov qab mus rau txoj hlua html khiav kom zoo. Qhov no txhais tau hais tias tsis muaj kev nkag siab tsis zoo tuaj yeem ua rau hauv txoj hlua rov qab.

Koj siv NG khi li cas? Lus txhais thiab Kev siv Cov ng - khi lus qhia AngularJS los hloov cov ntsiab lus ntawm cov ntsiab lus HTML nrog tus nqi ntawm qhov muab hloov pauv, lossis kev qhia. Yog tias tus nqi ntawm qhov muab hloov pauv, lossis kev qhia, hloov pauv, cov ntsiab lus ntawm cov ntsiab lus HTML yuav raug hloov thiab.

Ntawm no, dab tsi yog sanitization hauv angular?

Kev huv huv hloov kho cov tswv yim, tig mus rau hauv tus nqi uas muaj kev nyab xeeb los ntxig rau hauv DOM. Hauv Angular kev huv huv nyob ntawm cov ntsiab lus, tus nqi uas tsis muaj teeb meem hauv CSS yog qhov txaus ntshai hauv URL. koj tuaj yeem nyeem txog cov ntsiab lus sib txawv ntawm no.

$SCE yog dab tsi?

Strict Contextual Escaping ( SCE ) yog hom uas AngularJS txwv kev khi rau tsuas yog ua kom ntseeg tau qhov tseem ceeb. Nws lub hom phiaj yog los pab sau cov lej hauv ib txoj hauv kev uas (a) muaj kev nyab xeeb los ntawm lub neej ntawd, thiab (b) ua rau kev tshuaj xyuas kev ruaj ntseg xws li XSS, clickjacking, thiab lwm yam yooj yim dua.

Pom zoo: