שגיאה בהכנסת תגית HTML

saar85

New member
שגיאה בהכנסת תגית HTML

שלום. יש לי פקד ASP:TextBox עכשיו ברגע שאני מכניס לו טקסט שמכיל HTML אז אני מקבל שגיאה
A potentially dangerous Request.Form value was detected from the client (tb="<br>"). Description: Request Validation has detected a potentially dangerous client input value, and processing of the request has been aborted. This value may indicate an attempt to compromise the security of your application, such as a cross-site scripting attack. You can disable request validation by setting validateRequest=false in the Page directive or in the configuration section. However, it is strongly recommended that your application explicitly check all inputs in this case. Exception Details: System.Web.HttpRequestValidationException: A potentially dangerous Request.Form value was detected from the client (tb="<br>"). Source Error: An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.​
איך אני פותר את הבעיה?
 

24sharon

New member
תוסיף

ValidateRequest="false" בתגית הPAGE. אבל באמת תבדוק שלא מעבירים לך מידע "שאתה לא מעוניין בו" בהצלחה!
 

itzikbs

New member
ValidateRequest לא הייתי ממליץ

הפתרון להעברת HTML (שיכול להכיל הכל כולל JS ...) הוא לא לבטל כליל את האבטחה על כל העמוד - כלומר על כל ה Request אלא לבצע זאת על פי צורך בלבד. כלומר לשהתמש ב HtmlEncode ו HtmlDecode בכל "צד" ובכך לפתור את העניין ביי איציק ב.
 

J u n k y

New member
אלמנטרי, ווטסון

זו הגנה מובנית של ASP.NET מפני XSS (חבלה ע"י שתילת סקריפטים באתר דרך ממשק המשתמש). בדיפולט, לא ניתן להכניס תוים שמזכירים תגיות HTML כקלט מהמשתמש. אתה יכול לתפור את זה ע"י מה ששרון אמרה, אבל יש בזה סיכון מסוים. מה שאני עושה: במערכת האדמין אני מבטל את ההגנה, באתר עצמו אני משאיר אותה.
 

saar85

New member
הקטע...

שהתיבת טקסט אמורה להיות תוכן הודעה בפורום שאני בונה ופעמים ירצו להעלות קוד לפורום אז צריך את זה... בכל מקרה תודה. עכשיו עוד שאלה... יש אוליי איזה משהו מובנה שאפשר לשים שצובע קוד?
 

J u n k y

New member
בעעע

לא עושים דבר כזה בחיים - לא נותנים למשתמש נן השורה להכניס תגיות HTML. מה שעושים זה מכניסים תגיות משלך (משהו כמו |link=''|) ובשרת מחליפים לתגיות HTML "אמיתיות". מה הכוונה "צובע קוד" ב - VS?
 

J u n k y

New member
הפתרון שעולה לי לראש

הוא Regex עצבני + XML לכל המילים השמורות שאתה רוצה להכחיל.
 

saar85

New member
באתר Webmaster.org.il

יש את זה. מעניין איך הם עשו את זה
 

24sharon

New member
בטוח ניתן למצוא כאלו

כבר מוכנים ברשת, רק צריך זמן 'לחפש' אותם. במידה ולמישהו קיים כזה דבר, גם אני אשמח לקבל.
 
למעלה