CSC/ECE 517 Fall 2018- Project E1846. OSS Project Navy: Character Issues: Difference between revisions

From Expertiza_Wiki
Jump to navigation Jump to search
No edit summary
No edit summary
Line 36: Line 36:
1.Adding the functionality of ‘sanitize’ to specific html popups such as answer, comments and additional_comment which strips them of the html tags and thus ensures in the solution of our 2nd problem.<br>
1.Adding the functionality of ‘sanitize’ to specific html popups such as answer, comments and additional_comment which strips them of the html tags and thus ensures in the solution of our 2nd problem.<br>


<td align = 'center'> <%= sanitize s.answer %></td> <br>
<td align = 'center'> <%= sanitize s.answer %></td><br>


<td align = 'left'> <%= sanitize s.comments %> </td> <br>
<td align = 'left'> <%= sanitize s.comments %> </td><br>


<td> <%= sanitize @response.additional_comment %> </td> <br>
<td> <%= sanitize @response.additional_comment %> </td><br>


== Testing Details==
== Testing Details==

Revision as of 00:28, 2 November 2018

E1846. OSS Project Navy: Character Issues Fall 2018, CSC/ECE 517.

Problem Statement

As a part of our problem discussion, in the existing Expertiza DB, only UTF-8 characters are supported. So, if a user enters a non UTF-8 character, the DB throws an error while saving. The scenario we are focusing on is when a user types in a Chinese comma instead of a normal comma in a review, and then their entire review is lost when they try to submit. So, the task at hand is that before saving a review, we need to check if it contains any non UTF-8 characters and then parse the text to remove any such characters.

The second task is that after we review, the HTML tags appearing in review text need to be escaped. In essence, the review content needs to be stripped of the HTML tags enclosing it when displayed as they appeared in the display when viewed.

Files Refactored

The following files were modified for this project namely:
1. application_controller
2. self_review_popup

Solution Approach

The following changes were made in the app/controllers/application_controller.rb file:-

1.We defined the following before_action: filter_ascii 2. The following methods were defined by us

  i.  filter_ascii
This method makes a recursive call to the remove_ascii method.


  ii. remove_ascii
This method is a recursive hashing function that checks the input params and then removes the Chinese non-UTF-8 comma or any such characters and then saves this value.
  iii. self.verify
This function is just as its name suggests to verify the valid input.

3. The above changes were also made to make the code follow ruby style and guidelines.

The following changes were made in the apps/views/popup/self_review_popup.html.erb file:-

1.Adding the functionality of ‘sanitize’ to specific html popups such as answer, comments and additional_comment which strips them of the html tags and thus ensures in the solution of our 2nd problem.

<%= sanitize s.answer %>
<%= sanitize s.comments %>
<%= sanitize @response.additional_comment %>

Testing Details

RSpec

We found no existing test cases for the above two problem statements. So we are to define test cases which generate the list of unwanted Chinese non-UTF8 characters and also HTML tags in the views and then refactor our code so that it automatically removes them without any failing of functionalities.

References

  1. [1]