Giter VIP home page Giter VIP logo

Comments (6)

a2937 avatar a2937 commented on June 14, 2024

So for the authors page project, we probably need to add a step where step 16 is currently at that deals with sanitizing the data. I think we should consider adding some innocent but demonstrative bad data into our API. Stuff like special characters before it can actually be displayed on the page. At minimum, adding some less than and greater than symbols that need encoded could help.

As for forum leaderboard project, roughly around step 11 is where we should do the same thing.

from freecodecamp.

ShaunSHamilton avatar ShaunSHamilton commented on June 14, 2024

Because we are not exactly set up for modules, we might want to go the route of:

You could insert the data into your element by setting the innertHTML property. However, this exposes your page to _____. Instead, use the innerText property to insert the data: ....

from freecodecamp.

jdwilkin4 avatar jdwilkin4 commented on June 14, 2024

Instead, use the innerText property to insert the data:

innerText doesn't work though

Are you suggesting to make this change?

   authorContainer.innerText += `
    <div id="${index}" class="user-card">
      <h2 class="author-name">${author}</h2>
      <img class="user-img" src="${image}" alt="${author} avatar">
      <div class="purple-divider"></div>
      <p class="bio">${bio.length > 50 ? bio.slice(0, 50) + '...' : bio}</p>
      <a class="author-link" href="${url}" target="_blank">${author} author page</a>
    </div>
  `;

because if so, it would produce this result

Screenshot 2024-04-29 at 6 22 01 AM

from freecodecamp.

ShaunSHamilton avatar ShaunSHamilton commented on June 14, 2024

Are you suggesting to make this change?

No, I suggest splitting the stuff we control and the text into different parts.

I see why that might not work very easily; Previously, I had just looked at the forum leaderboard:

const showLatestPosts = (data) => {
  const { topic_list, users } = data;
  const { topics } = topic_list;

  postsContainer.innerHTML = topics.map((item) => {
    const {
      id,
      title,
      views,
      posts_count,
      slug,
      posters,
      category_id,
      bumped_at,
    } = item;

    return `
    <tr>
      <td>
        <p class="post-title">${title}</p>

        ${forumCategory(category_id)}
      </td>
      <td>
        <div class="avatar-container">
          ${avatars(posters, users)}
        </div>
      </td>
      <td>${posts_count - 1}</td>
      <td>${viewCount(views)}</td>
      <td>${timeAgo(bumped_at)}</td>
    </tr>`;
  }).join("");
};

from freecodecamp.

jdwilkin4 avatar jdwilkin4 commented on June 14, 2024

No, I suggest splitting the stuff we control and the text into different parts.

That might work.

We technically control all of the content for the authors page project since it is just a hardcoded json file
https://github.com/freeCodeCamp/cdn/blob/main/build/curriculum/news-author-page/authors.json

from freecodecamp.

moT01 avatar moT01 commented on June 14, 2024

It could be enough to just use textContent or innerText where we can and explain that "usually you would sanitize the data" or something. I guess wouldn't prefer that. This kinda seems like a good place to teach it.

from freecodecamp.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.