Commit Graph

58 Commits

Author SHA1 Message Date
Isaac Moore d6584b490a Remove unnecessary require statements
closes AE-30

flag=none

test plan:
- verify Canvas boots in CD
- verify no influx of new errors in CD

[fsc-timeout=30]

Change-Id: Ifa04bebe1b09f01c6d3b8b2d8f3bb424759730f5
Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/308067
Tested-by: Service Cloud Jenkins <svc.cloudjenkins@instructure.com>
Reviewed-by: Jacob Burroughs <jburroughs@instructure.com>
QA-Review: Isaac Moore <isaac.moore@instructure.com>
Product-Review: Isaac Moore <isaac.moore@instructure.com>
Build-Review: James Butters <jbutters@instructure.com>
2023-01-04 21:38:21 +00:00
Aaron Ogata 0ca2cd5eb3 fix Nokogiri::HTML5.fragement call kwargs
refs AE-92

Change-Id: Ie40874b4e53b4e4a11eafcd5026a692cf32dcd31
Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/307086
Reviewed-by: Andrea Cirulli <andrea.cirulli@instructure.com>
QA-Review: Aaron Ogata <aogata@instructure.com>
Product-Review: Aaron Ogata <aogata@instructure.com>
Tested-by: Service Cloud Jenkins <svc.cloudjenkins@instructure.com>
2022-12-09 20:22:13 +00:00
Jackson Howe 53d433019b Increase depth limit for syllabus
User content with deeply nested html elements couldn't be parsed by
Nokogiri when the depth exceeded the DEFAULT_MAX_TREE_DEPTH of 400.
The depth limit has already been increased in other places (quizzes,
wiki pages), so we'll do the same for syllabus content to prevent making
the entire syllabus inaccessible if deeply nested content is saved. This
change also prevents content that can't be parsed from being saved in
the syllabus.

fixes LS-3114
flag = none

Test plan:
 - Get my document with deeply-nested html and save the content to a
   course's syllabus_body in a rails console
 - Go to that course's syllabus in the UI
 - Expect the page to load fine
 - Lower the max_tree_depth constant in
   gems/canvas_sanitize/lib/canvas_sanitize/canvas_sanitize.rb (L75) to 1
 - Restart rails server
 - In a new course, go to the syllabus and in the html editor, paste
   <div><div><p>hi</p></div></div>
 - Click save and expect to get a 4xx response

Change-Id: Ib97ab86c102162f8efdc29c1122e0aa6d9801026
Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/289992
Reviewed-by: Eric Saupe <eric.saupe@instructure.com>
QA-Review: Eric Saupe <eric.saupe@instructure.com>
Product-Review: Jackson Howe <jackson.howe@instructure.com>
Tested-by: Service Cloud Jenkins <svc.cloudjenkins@instructure.com>
2022-04-20 19:38:27 +00:00
Weston Dransfield 3e3c1072e6 Remove new_math_equation_handling flag
Closes MAT-136
flag=none

Note that we cannot completely remove the
branching logic at this point.

We still need the old behavior for handling
a few bits of quizzes.

This commit, however, does remove the feature
flag

Test Plan:
- Verify the flag is no longer available for
  root accounts to set
- Create a page in a course with equations
  and verify MathJax is used to typset the
  equation when viewed.
- Edit a quizz or view question banks and
  verify MathJax is not used to typset
  equations in those views

Change-Id: I9e5524c4da6597b6c8fa26e5fbd1ba9d7e6b0f49
Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/280911
Tested-by: Service Cloud Jenkins <svc.cloudjenkins@instructure.com>
Reviewed-by: Juan Chavez <juan.chavez@instructure.com>
QA-Review: Juan Chavez <juan.chavez@instructure.com>
Product-Review: David Lyons <lyons@instructure.com>
2021-12-15 17:48:07 +00:00
Cody Cutrer c2cba46851 RuboCop: Style/StringLiterals, Style/StringLiteralsInInterpolation
[skip-stages=Flakey]

auto-corrected

Change-Id: I4a0145abfd50f126669b20f3deaeae8377bac24d
Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/279535
Tested-by: Cody Cutrer <cody@instructure.com>
QA-Review: Cody Cutrer <cody@instructure.com>
Product-Review: Cody Cutrer <cody@instructure.com>
Migration-Review: Cody Cutrer <cody@instructure.com>
Reviewed-by: Jacob Burroughs <jburroughs@instructure.com>
2021-11-25 14:03:06 +00:00
Cody Cutrer e905d82fb9 RuboCop: Style/StructInheritance
auto-corrected

Change-Id: Id4fa8fb70832f39635aa2bd1196d87f1c4f5cde8
Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/278957
Tested-by: Service Cloud Jenkins <svc.cloudjenkins@instructure.com>
Reviewed-by: Jacob Burroughs <jburroughs@instructure.com>
QA-Review: Cody Cutrer <cody@instructure.com>
Product-Review: Cody Cutrer <cody@instructure.com>
2021-11-19 22:38:42 +00:00
Cody Cutrer 5067ecfb56 RuboCop: Style/ExplicitBlockArgument
[skip-stages=Flakey]

auto-corrected

Change-Id: I73d924591db9441458f2f128f6182d80da7e2cf1
Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/278358
Tested-by: Service Cloud Jenkins <svc.cloudjenkins@instructure.com>
Reviewed-by: Jacob Burroughs <jburroughs@instructure.com>
QA-Review: Cody Cutrer <cody@instructure.com>
Product-Review: Cody Cutrer <cody@instructure.com>
2021-11-17 20:04:02 +00:00
Cody Cutrer 9792b6780d RuboCop: Performance/RedundantBlockCall
[skip-stages=Flakey]

auto-corrected, with a few post-correction tweaks

Change-Id: Ic8ad959a4c331ae879644f473ffda20e63e353e9
Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/278341
Tested-by: Service Cloud Jenkins <svc.cloudjenkins@instructure.com>
Reviewed-by: Jacob Burroughs <jburroughs@instructure.com>
QA-Review: Cody Cutrer <cody@instructure.com>
Product-Review: Cody Cutrer <cody@instructure.com>
2021-11-17 20:03:24 +00:00
Cody Cutrer fe3c624016 RuboCop: Performance/RedundantSplitRegexpArgument
[skip-stages=Flakey]

auto-corrected

Change-Id: Ic9b7b8d4c3b1d76c32d8e9645cf5208002737645
Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/278321
Tested-by: Service Cloud Jenkins <svc.cloudjenkins@instructure.com>
Reviewed-by: Simon Williams <simon@instructure.com>
QA-Review: Cody Cutrer <cody@instructure.com>
Product-Review: Cody Cutrer <cody@instructure.com>
2021-11-16 16:35:46 +00:00
Cody Cutrer 294d98c6fd RuboCop: Style/MutableConstant
auto-corrected

Change-Id: Ib1b3c85711578a33014ea90f0662bd46f7b2288b
Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/278214
Tested-by: Service Cloud Jenkins <svc.cloudjenkins@instructure.com>
Reviewed-by: Simon Williams <simon@instructure.com>
QA-Review: Cody Cutrer <cody@instructure.com>
Product-Review: Cody Cutrer <cody@instructure.com>
2021-11-16 16:19:54 +00:00
Cody Cutrer 3512a9557e RuboCop: Style/SafeNavigation
[skip-stages=Flakey]

auto-corrected

Change-Id: I0a907a6fa6229f05b4f756faf53a8dd2b18ea0c5
Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/278213
Tested-by: Service Cloud Jenkins <svc.cloudjenkins@instructure.com>
Reviewed-by: Simon Williams <simon@instructure.com>
QA-Review: Cody Cutrer <cody@instructure.com>
Product-Review: Cody Cutrer <cody@instructure.com>
2021-11-16 06:36:38 +00:00
Cody Cutrer a690e90aa8 RuboCop: Style/RedundantReturn
[skip-stages=Flakey]

auto-corrected

Change-Id: Ic472ca1cc04423fc966cd4a1ead467604d2904fc
Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/278130
Tested-by: Service Cloud Jenkins <svc.cloudjenkins@instructure.com>
Reviewed-by: Simon Williams <simon@instructure.com>
QA-Review: Cody Cutrer <cody@instructure.com>
Product-Review: Cody Cutrer <cody@instructure.com>
2021-11-12 16:33:45 +00:00
Cody Cutrer 299314b162 RuboCop: Style/NegatedIf
auto-corrected

Change-Id: Ieab0b9525c1342f900721196c6694bef17378ec0
Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/278024
Tested-by: Service Cloud Jenkins <svc.cloudjenkins@instructure.com>
Reviewed-by: Simon Williams <simon@instructure.com>
QA-Review: Cody Cutrer <cody@instructure.com>
Product-Review: Cody Cutrer <cody@instructure.com>
2021-11-11 22:55:11 +00:00
Cody Cutrer a498023706 RuboCop: Performance/StringReplacement
auto-corrected

Change-Id: I4df9529bd8d09d9f96e979d59120f126fe2b8761
Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/278006
Tested-by: Service Cloud Jenkins <svc.cloudjenkins@instructure.com>
Reviewed-by: Simon Williams <simon@instructure.com>
QA-Review: Cody Cutrer <cody@instructure.com>
Product-Review: Cody Cutrer <cody@instructure.com>
2021-11-11 22:00:48 +00:00
Cody Cutrer f23a4917d7 RuboCop: Style/RedundantRegexpEscape
[skip-stages=Flakey]

auto-corrected

Change-Id: I21b955242be4150034f8188eb24049cd1204956d
Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/277883
Tested-by: Service Cloud Jenkins <svc.cloudjenkins@instructure.com>
Reviewed-by: Simon Williams <simon@instructure.com>
QA-Review: Cody Cutrer <cody@instructure.com>
Product-Review: Cody Cutrer <cody@instructure.com>
2021-11-11 02:19:02 +00:00
Cody Cutrer a0a399136a RuboCop: Lint/UnusedBlockArgument config,doc,gems,lib
all manual

Change-Id: I8bb9c11634b0e2b2c8a79dd6f8f2cb71eaa90450
Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/276628
Tested-by: Service Cloud Jenkins <svc.cloudjenkins@instructure.com>
Reviewed-by: Jacob Burroughs <jburroughs@instructure.com>
QA-Review: Cody Cutrer <cody@instructure.com>
Product-Review: Cody Cutrer <cody@instructure.com>
2021-10-27 22:30:15 +00:00
Cody Cutrer 58d528037e RuboCop: Lint/AssignmentInCondition
[skip-stages=Flakey]

(manual)

Change-Id: I855b13a7888f4926df42fe6306cc248e611efdf6
Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/274712
Tested-by: Service Cloud Jenkins <svc.cloudjenkins@instructure.com>
Reviewed-by: Simon Williams <simon@instructure.com>
QA-Review: Cody Cutrer <cody@instructure.com>
Product-Review: Cody Cutrer <cody@instructure.com>
2021-09-29 03:38:39 +00:00
Cody Cutrer c65d57737a RuboCop: Layout lib
Change-Id: I0655d9a9d750f2debd6378b03d8ddc1403ebc31b
Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/274158
Tested-by: Service Cloud Jenkins <svc.cloudjenkins@instructure.com>
Reviewed-by: Simon Williams <simon@instructure.com>
QA-Review: Cody Cutrer <cody@instructure.com>
Product-Review: Cody Cutrer <cody@instructure.com>
2021-09-22 20:01:52 +00:00
Eric Saupe 319f5b45e7 Revert "Remove bad mailto links"
This reverts commit 77f62a52a6.

refs LS-2622

Change-Id: Ie73c00fffbf1fc2f62448797ca0022feed8998bc
Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/273715
Reviewed-by: Jeremy Stanley <jeremy@instructure.com>
QA-Review: Jeremy Stanley <jeremy@instructure.com>
Product-Review: Jeremy Stanley <jeremy@instructure.com>
Tested-by: Service Cloud Jenkins <svc.cloudjenkins@instructure.com>
2021-09-16 17:38:05 +00:00
Eric Saupe 77f62a52a6 Remove bad mailto links
fixes LS-2622
flag=none

test plan:
- Create a wiki page on a course with two mailto links in the content.
One with a valid email address string and one with an invalid string.
- Export the course.
- Verify the bad mailto link has been removed but the text is still
there.
- Copy the course to another.
- Verify the bad mailto link has been removed but the text is still
there.

Change-Id: I2277d420c5cd7339df197ebbaf983c3ed0e7d6a0
Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/273648
Tested-by: Service Cloud Jenkins <svc.cloudjenkins@instructure.com>
Reviewed-by: Isaac Moore <isaac.moore@instructure.com>
QA-Review: Isaac Moore <isaac.moore@instructure.com>
Product-Review: Eric Saupe <eric.saupe@instructure.com>
2021-09-16 17:06:41 +00:00
Eric Saupe dc1069ce81 Handle links to course home in course copy
fixes LS-2325
flag=none

test plan:
- Create a page
- In the content of the page create a link to the course home by clicking
 the dropdown next to the link button in the RCE menu, then clicking
 Course Links, expand Course Navigation, then select Home
- With the Home link in the content, save the page
- Export the course
- Import the course content into a new course
- Verify the link in the imported page content is linked to the new page's
 home navigation and not the old course
- Also verify just using the Copy Course from Import Course Content also
 changes the home navigiation link as expected

Change-Id: Ib7779a4c42f9669ac4da6408a2fbd453ae31a039
Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/267975
Tested-by: Service Cloud Jenkins <svc.cloudjenkins@instructure.com>
Reviewed-by: Jackson Howe <jackson.howe@instructure.com>
QA-Review: Jackson Howe <jackson.howe@instructure.com>
Product-Review: Eric Saupe <eric.saupe@instructure.com>
2021-06-29 15:36:21 +00:00
Cody Cutrer 160ff3c899 bump sanitize to latest
[fsc-max-nodes=12]
[fsc-timeout=60]

 * switch lots of parsing to Nokogumbo to keep things consistent
 * deep CSS sanitization is now built in, and with a proper parser (meaning
   we can drop our code to do it, and adjust some specs to account for things
   that _are_ valid)

lots of changes because gumbo parsing<->serialization cycle is slightly different:
 * better job preserving original whitespace
 * literal non-breaking space characters are converted to &nbsp; entities
 * <p> tags aren't inserted for the heck of it
 * several _other_ entities are unnecessary, and output as literal characters
 * some elements no longer have a closing tag

Change-Id: I7c5e36cbd04b8a05f64c9e0af00868dd6b00f4ce
Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/256444
Tested-by: Service Cloud Jenkins <svc.cloudjenkins@instructure.com>
Reviewed-by: Jacob Burroughs <jburroughs@instructure.com>
QA-Review: Cody Cutrer <cody@instructure.com>
Product-Review: Cody Cutrer <cody@instructure.com>
2021-02-17 18:17:57 +00:00
Ed Schiebel 567512cf47 Quiz math fixup bug fixes
closes LS-1685
flag=none

test plan:
  - when a quiz is fixed-up, the tooltips on equation answers should
    be reasonable.
  - if we find inline latex burried in the sea of html-ish text
    it's extracted and turned into an equation image. Sadly
    I don't remember what quiz+question I discovered this on
    (though it was near the top of peyton's course)
  - when fixup generates equation images, the title has its closing
    quote, so the tooltip looks correct.

Change-Id: I21201b094c46ee057d1a6f779d120db303e31bca
Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/254544
Tested-by: Service Cloud Jenkins <svc.cloudjenkins@instructure.com>
Reviewed-by: Nate Armstrong <narmstrong@instructure.com>
QA-Review: Robin Kuss <rkuss@instructure.com>
Product-Review: Ed Schiebel <eschiebel@instructure.com>
2020-12-08 20:10:46 +00:00
Ed Schiebel f18777afe0 Don't use new math handling when editing quizzes
closes LS-1639
flag=none

The change to SyllabusBehaviors puts code back that existed
before the new math handling was introduced, and should have
been behind its flag.

If the new_math_equation_handling flag is on, turn it off if
we're editing a quiz, and skip having the backend inject the
hidden mathml, which is part of the legacy equation handling.

test plan:
=== With the new math_equation_handling flag off ====
  - create a quiz, add a multiple choice question with an equation
    as an answer
  - save the question, save the quiz
  - edit the quiz, edit the question, do not edit the answer
  > look at the DOM. there should be no moe than 1
    <span class="hidden-readable">
    just after the equation image in the answer
  - save the question, save the quiz
  - preview the quiz
  > expect just 1 <span class="hidden-readable"> in the DOM just
    after the equation image
  - no combination of edit, save, edit, ... should cause > 1
    <span class="hidden-readable">
    after the equation image

=== with the new_math_equation_handling flag on ===
  - preview and edit the quiz you created with the flag off
  > expect it to look A-OK

  - create a new quiz
  - use the rce's equation editor to put an equation everywhere
    you can possible think of in a quiz
    - the text
    - answers
    - comments on the answers
  > expect the equations to look right no matter what
    - edit the quiz and all the places where there are equations
    > yep still ok
    - save the qustion
    > still ok
    - save the quiz
    > still ok
    - preview the quiz, to completion to see answer comments
    > looks good _and_ equations are mathjaxified
    - edit everything again
    > still looks good everywhere

Change-Id: I1319d007509f6e8cbc9c9af81e3939e365b0fa92
Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/253507
Reviewed-by: Jackson Howe <jackson.howe@instructure.com>
Tested-by: Service Cloud Jenkins <svc.cloudjenkins@instructure.com>
QA-Review: Robin Kuss <rkuss@instructure.com>
Product-Review: Ed Schiebel <eschiebel@instructure.com>
2020-12-01 14:38:50 +00:00
Ed Schiebel 20be367527 Bug fix when turning off new_math_equation_handling
closes LS-1637
flag=none

When the flag is off, we weren't loading MathJAx at all, which is
bad. We need it to process hidden mathml for a11y support.

test plan:
  - in the rce add an equation and save
  > expect a span class=hidden-readable with mathjax'd mathml
    right after the image, or
  > use a screenreader, the equation should be read

Change-Id: I73dc5e6718ee9b9403f29825378965c679e03254
Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/253458
Reviewed-by: Charley Kline <ckline@instructure.com>
Tested-by: Service Cloud Jenkins <svc.cloudjenkins@instructure.com>
QA-Review: Robin Kuss <rkuss@instructure.com>
Product-Review: Keith Garner <kgarner@instructure.com>
2020-11-20 22:33:05 +00:00
Ed Schiebel 0fc8ce19f7 New approach to MathJax-ifying equations
closes LS-1601
flag=new_math_equation_handling

The previous approach was to replace the equation image with the
equation's LaTeX in canvas' backend, but not all user content sent
to the browser passes through UserContent.escape. Discussions
and legacy quiz questions included. The backend approach also suffered
from the an ugly visual where the LaTeX is displayed onscreen until
MathJax typesets it.

In a previous commit, I caught Discussion replies in apiUserContent
where the screenreader assistive mathml is injected into the DOM
adjacent to the image. That worked but we now had 2 places
where the replacement was taking place, and quiz questions are
still being missed.

A better approach is to handle it all in a central location, which
is with the code that detects math is on the page. The new approach
is to inject the LaTeX into the DOM adjacent to the image just before
MathJax does its processing, then removes the image when it finished.
This way the equation image is displayed to the user while MathJaX
does its work, and since we look for new math in a MutationObserver
watching the whole document, we never miss any equation images on the page.

Because we are looking for mutations anywhere on the page, there may
be nodes we want to ignore (e.g. the quiz timer). This is handled
by adding to the ignore_list css selector in main.js

test plan:
  - with the "Updated math equation handling" flag on
    (and optionally 'Support LaTex math equations almost everywhere")
  - double check that equations created with the rce equation editor
    are processed with mathjax all over canvas
  > expect equation images to be visible until replaced by MathJax
    typeset versions
  - Discussions:
    - reply to a discussion with an equation (inline and equation editor)
    > expect them to be typeset by mathjax
    - edit a reply and save
    > expect the the reply to have it's math processed by mathjax
  - Legacy Quizzes
    - create a quiz, set it so 1 question per page
    - add a couple questions with equations
    - preview the quiz, moving forward and back thru the questions
    > expect the questions go have their equations typeset by mathjax

Change-Id: I9e2ec4fd53de06748156bbd4adadac7e2b1e205f
Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/252222
Tested-by: Service Cloud Jenkins <svc.cloudjenkins@instructure.com>
Reviewed-by: Jackson Howe <jackson.howe@instructure.com>
QA-Review: Robin Kuss <rkuss@instructure.com>
Product-Review: Peyton Craighill <pcraighill@instructure.com>
2020-11-09 22:38:36 +00:00
Cody Cutrer 06763dd519 add # frozen_string_literal: true for lib
Change-Id: I59b751cac52367a89e03f572477f0cf1d607b405
Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/251155
Tested-by: Service Cloud Jenkins <svc.cloudjenkins@instructure.com>
Reviewed-by: Simon Williams <simon@instructure.com>
QA-Review: Cody Cutrer <cody@instructure.com>
Product-Review: Cody Cutrer <cody@instructure.com>
2020-10-27 20:49:50 +00:00
Ed Schiebel a992d05633 Update math equation rendering
This commit changes nothing in the RCE, but changes how canvas renders
equations in the resulting page. Rather than
adding mathml in a hidden span adjacent to the equation image for
MathJax to process, this change replaces the image with a span containing
the LaTex source for MathJax to format.  This is better for a couple
reasons.

MathJax is not intended for formatting equations as they are
being edited and dealing with MathJax processed equations in the RCE when you
may want to edit an existing equation is never going to work well.

The visible MathJax-ified equations in the resulting page provides the
accessiblity we require.

This approach will update all existing content with math images,
so old content gets the benefit too.

Contrary to what some believe, you will not be able to select, copy
and paste parts of an equation.

closes: LS-1401
flag=new_math_equation_handling

test plan:
  - with new_math_equation_handling flag on
  - insert a math equation in the RCE
  > notice that when you click on the equation's image, you do not
    get the "Image Options" popup button
  - click on the equation
  > expect the "Edit Equation" popup button, not "Image Options"
  - edit the equation and save
  > expect it to be updated
  - save the page
  > expect the equation to fade into view after being processed by MathJax.
  > expect the MathJax menu when you right click in it
  > expect screenreaders read it nicely
  - edit the page again
  > expect the equation as an image again.
  > expect to be able to edit the equation
  - switch your user to a different language
  - open a page with an equation and right-click in the eq.
  > expect the mathjax context menu to be in the user's language
    (assuming mathjax supports it)

Change-Id: Ieac6785d51c0cab475b1176712f46fc2c964ff71
Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/247471
Tested-by: Service Cloud Jenkins <svc.cloudjenkins@instructure.com>
Reviewed-by: Jackson Howe <jackson.howe@instructure.com>
QA-Review: Daniel Sasaki <dsasaki@instructure.com>
Product-Review: Peyton Craighill <pcraighill@instructure.com>
2020-09-16 13:53:04 +00:00
Jeremy Stanley e2c28d9010 don't replace part of an absolute path in HtmlRewriter
yes, this is terrible, but it's less bad than breaking URLs entirely
which is what we did before

test plan:
 - upload an image to a course
 - put the following in a quiz description using the HTML editor:
   <img src="http://localhost:3000/files/3603/download?download_frd=1">
   (substitute the hostname and id of the image)
 - ensure the image shows up when viewing the quiz
 - copy the course
 - ensure the image shows up when viewing the quiz in the copy

fixes ADMIN-1103

Change-Id: I4b1914a7dd8baa1d03cf739163cdbf0e164e56da
Reviewed-on: https://gerrit.instructure.com/152470
Reviewed-by: James Williams  <jamesw@instructure.com>
Tested-by: Jenkins
QA-Review: Luke Kingsley <lkingsley@instructure.com>
Product-Review: Jeremy Stanley <jeremy@instructure.com>
2018-06-06 21:30:28 +00:00
Jeremy Stanley 19893a75fa preserve query params in links in migrations
test plan:
 - have a course with a wiki page and assignment
 - create another page that embeds the two former items
   in an iframe with "?embedded=true" in the link
   as described in the ticket
 - copy the course
 - in the copy, the "?embedded=true" links should be
   preserved

fixes ADMIN-868

Change-Id: I20c775cbd8a76eabecf49252b61a45d0a7817278
Reviewed-on: https://gerrit.instructure.com/147898
Tested-by: Jenkins
Reviewed-by: James Williams  <jamesw@instructure.com>
QA-Review: Deepeeca Soundarrajan <dsoundarrajan@instructure.com>
Product-Review: Jeremy Stanley <jeremy@instructure.com>
2018-04-26 16:35:52 +00:00
James Williams 5c4fa22735 fix contextless file link translation some more
test plan:
* make sure that links like
 "https://example.com/files" are preserved on copy
 but links to "/courses/:course_id/files" are
 translated to the new course

closes #ADMIN-805

Change-Id: Ia7cd5ba5ea61fa05c8edb0cfc4d413b667aae5fd
Reviewed-on: https://gerrit.instructure.com/141728
Reviewed-by: Jeremy Stanley <jeremy@instructure.com>
Tested-by: Jenkins
QA-Review: Deepeeca Soundarrajan <dsoundarrajan@instructure.com>
Product-Review: James Williams  <jamesw@instructure.com>
2018-03-01 01:39:38 +00:00
James Williams 481a7e45e8 fix non-course url translation in course copy
test plan:
* links to external domains with url's similar
 to canvas links, e.g. "https://example.com/users/1"
 should not be modified on course copy

closes #ADMIN-754

Change-Id: Ie2f55f8a1806528da7631b00f6876bc0ac3f77d7
Reviewed-on: https://gerrit.instructure.com/140421
Tested-by: Jenkins
Reviewed-by: Jeremy Stanley <jeremy@instructure.com>
QA-Review: Deepeeca Soundarrajan <dsoundarrajan@instructure.com>
Product-Review: James Williams  <jamesw@instructure.com>
2018-02-09 19:32:50 +00:00
James Williams 0db73148fa translate contextless file links in course copies
if we run into a link directly to "/files/X" we
 should try to pass it through to the other course
 instead of leaving it alone

Change-Id: Ie67add5553ec9fbb2a7e2acaf0274cf798eb6b4f
Reviewed-on: https://gerrit.instructure.com/135074
Reviewed-by: Jeremy Stanley <jeremy@instructure.com>
Tested-by: Jenkins
Product-Review: James Williams  <jamesw@instructure.com>
QA-Review: James Williams  <jamesw@instructure.com>
2017-12-18 13:43:32 +00:00
Landon Wilkins 45b8efda41 da licença part 36
add consistent license headers to all source files

Change-Id: I15e544768e7361fc050089a5ed4699f7ee96bb2c
Reviewed-on: https://gerrit.instructure.com/110064
Tested-by: Jenkins
Reviewed-by: Jon Jensen <jon@instructure.com>
Product-Review: Jon Jensen <jon@instructure.com>
QA-Review: Jon Jensen <jon@instructure.com>
2017-04-28 17:31:17 +00:00
Blake Allan 9a04032a6d add 'LaTeX: ' prefix to the equation alt attributes from equation editor
Fixes: CNVS-29738

Test Plan:
With an RCE view open, click the insert math equation button
Create a math equation and click insert equation
Ensure that the equation image alt attribute is prefixed by 'LaTeX: '

Change-Id: I6df61e83de9820f54757bbfdd3065275889df88c
Reviewed-on: https://gerrit.instructure.com/102708
Tested-by: Jenkins
Reviewed-by: Simon Williams <simon@instructure.com>
QA-Review: Jeremy Putnam <jeremyp@instructure.com>
Product-Review: Simon Williams <simon@instructure.com>
2017-03-14 04:45:00 +00:00
John Corrigan c9e0fa96a3 enable use of MathMan for latex => mathml conversion
fixes CNVS-59514

Also adds a MathMan module that wraps some convenience methods for 1-
figuring out if it's ok to use mathman; 2- constructing urls for hitting
mathman's endpoints.

test plan:

*With Ritex*

- Add an assignment (or some type of content with a description editable
  via tinymce / rcs).
- Update the description to include a latex equation using the equation
  editor.
- Upon saving the assignment, observe that an image of the equation is
  visible.
- Using the browser's elemnt / DOM inspector, select the equation image,
  and observe that there is a hidden span that contain a math ml
  representation.

*With Mathman*

- Navigate to an account's plugin page, and select the MathMan plugin.
- On the edit screen, enable the plugin, and provide a working mathman
  base url and check the 'Use for mml' checkbox. Save the changes.
- Add an assignment (or some type of content with a description editable
  via tinymce / rcs).
- Update the description to include a latex equation using the equation
  editor.
- Upon saving the assignment, observe that an image of the equation is
  visible.
- Using the browser's elemnt / DOM inspector, select the equation image,
  and observe that there is a hidden span that contain a math ml
  representation.

Change-Id: I194d155b339123f7ed1948cf29070c1d17fc7f17
Reviewed-on: https://gerrit.instructure.com/84031
Tested-by: Jenkins
Reviewed-by: Simon Williams <simon@instructure.com>
QA-Review: Benjamin Christian Nelson <bcnelson@instructure.com>
Product-Review: John Corrigan <jcorrigan@instructure.com>
2016-08-05 15:31:23 +00:00
John Corrigan 9c4bc621ff add statsd capturing to ritex mml generation
fixes CNVS-29811

test plan:
- Create an assignment (or any content type with a body / description
  that uses RCS).
- Add a formula to the body / description.
- Observe that the formula is displayed.

Change-Id: I5c7ab3e1ba74c12654ac341983749122424ab6c4
Reviewed-on: https://gerrit.instructure.com/81691
Tested-by: Jenkins
Reviewed-by: Simon Williams <simon@instructure.com>
QA-Review: Benjamin Christian Nelson <bcnelson@instructure.com>
Product-Review: John Corrigan <jcorrigan@instructure.com>
2016-06-08 18:55:53 +00:00
James Williams 12bd2627ab remove float rounding monkey-patch
used to turn 1.0.to_s to "1"

closes #CNVS-28310

Change-Id: I79106a4c0b42fe9b6d96097aaf9dd28a43024373
Reviewed-on: https://gerrit.instructure.com/75194
Reviewed-by: Cody Cutrer <cody@instructure.com>
Reviewed-by: Jeremy Stanley <jeremy@instructure.com>
Tested-by: Jenkins
QA-Review: KC Naegle <knaegle@instructure.com>
Product-Review: James Williams  <jamesw@instructure.com>
2016-04-22 18:17:18 +00:00
James Williams 878e91cca1 fix course link references for users without :manage_content
test plan:
* create a course with a locked discussion topic
* add a link to the discussion topic to a wiki page

* create a term with dates for teachers in the past
* add the course to the past term

* as a teacher, copy the course
* the link in the wiki page should point to the
 correct discussion topic in the copied course

closes #CNVS-27143

Change-Id: Ic7e72276e88c54a35346f5863fb141eedd44905f
Reviewed-on: https://gerrit.instructure.com/72014
Tested-by: Jenkins
QA-Review: Jahnavi Yetukuri <jyetukuri@instructure.com>
Reviewed-by: Jeremy Stanley <jeremy@instructure.com>
Product-Review: James Williams  <jamesw@instructure.com>
2016-02-16 16:20:21 +00:00
Simon Williams 67257f3dac stop stripping alt tag when generating mathml
this also fixes and issue where subsequent edits fail to generate mathml
successfully.

fixes CNVS-22762

test plan:
- in all browsers
- create an equation image, save, inspect
- edit page, re-save, inspect
- make sure things look right visually and for screenreaders

Change-Id: Ice5de7be720b217aa19850233e11fdf238d68158
Reviewed-on: https://gerrit.instructure.com/68372
Tested-by: Jenkins
Product-Review: Aaron Cannon <acannon@instructure.com>
Reviewed-by: Rob Orton <rob@instructure.com>
QA-Review: August Thornton <august@instructure.com>
2015-12-14 17:08:47 +00:00
Jacob Fugal fee02186e7 gracefully handle latex parse errors
fixes CNVS-21975

test-plan:
 - put some invalid latex in an equation image
 - save and load
 - should not be a page error
 - equation image's alt attribute should still have the unprocessed
   latex

Change-Id: I635a042c11d9344d05f89c9ae5cdb9aff75eea13
Reviewed-on: https://gerrit.instructure.com/58783
Reviewed-by: Ryan Shaw <ryan@instructure.com>
QA-Review: Ben Bolton <bbolton@instructure.com>
Product-Review: Jacob Fugal <jacob@instructure.com>
Tested-by: Jenkins
2015-07-18 18:47:34 +00:00
Ethan Vizitei be832e9da1 make mathml work in all tinymce areas
closes CNVS-20200

first, takes the mathml translation we already know how to do
and stuffs that in a data element on equation images

second, extract mathml from data attribute and inject as a
screenreader span to make the mathml consumable.

I also reworked the "convertApiUserContent" coffee function to
be a little more broken up and individually testable (and
added specs for it), and made sure not to do this transformation
when editing (as that would start a content update loop where
we add content on every save/edit cycle)

TEST PLAN:
 For each of the following places, make sure you can save
  an equation image in the tinymce editor and get MATHML for
  screeenreaders in the output:

  Announcement reply
  Discussion reply
  Wiki Page body
  Outcome description
  Quiz essay answer text
  ePortfolio page edit

Regression test mathml generation in other tinymce areas (which were
already producing it)

Change-Id: Icc769dc92e799563133d47c8dda8ea84fde034eb
Reviewed-on: https://gerrit.instructure.com/56029
Tested-by: Jenkins
Reviewed-by: Jason Madsen <jmadsen@instructure.com>
QA-Review: Jeremy Putnam <jeremyp@instructure.com>
Product-Review: Ethan Vizitei <evizitei@instructure.com>
2015-06-11 22:52:58 +00:00
Strand McCutchen 1a24af8e53 fix Lint/StringConversionInInterpolation issue
Change-Id: Ibea00b023aa91e4f4a627161fbe87dbb54d22daf
fixes: CNVS-20009
Reviewed-on: https://gerrit.instructure.com/52884
Reviewed-by: Cody Cutrer <cody@instructure.com>
Tested-by: Jenkins
Product-Review: Strand McCutchen <smccutchen@instructure.com>
QA-Review: Strand McCutchen <smccutchen@instructure.com>
2015-04-27 20:53:25 +00:00
Cody Cutrer 9834937c8c don't autorequire a bunch of gems that are rarely used
Change-Id: I09ed3686629b62849d392684d587f30cb2047013
Reviewed-on: https://gerrit.instructure.com/51853
Tested-by: Jenkins
Reviewed-by: Ethan Vizitei <evizitei@instructure.com>
Product-Review: Cody Cutrer <cody@instructure.com>
QA-Review: Cody Cutrer <cody@instructure.com>
2015-04-09 18:47:50 +00:00
Cody Cutrer d57b057ada reduce loading interdependencies from Context
by referencing symbols, just loading Context doesn't immediately cause
all the other stuff (and their dependents) to be loaded

Change-Id: I90e939ea03b628435ba77e2dc9ea886bf3f837c4
Reviewed-on: https://gerrit.instructure.com/51801
Tested-by: Jenkins
Reviewed-by: Ethan Vizitei <evizitei@instructure.com>
Product-Review: Cody Cutrer <cody@instructure.com>
QA-Review: Cody Cutrer <cody@instructure.com>
2015-04-09 17:00:08 +00:00
Jacob Fugal d9c6e2a0cd clarify Slug vs. UUID and fix event stream
refs CNVS-13987

what was called CanvasUuid was *not* generating UUIDs. it was generating
slugs. by default, its generate method only creates 4 character slugs.
these should obviously not be used as UUIDs. the misnomer already caused
a bug in EventStream where it used these slugs as UUIDs, causing
collisions. to fix:

 (1) rename canvas_uuid gem to canvas_slug, and rename it's primary
     class CanvasUuid to CanvasSlug
 (2) create new canvas_uuid gem, with class CanvasUUID, extracted from
     lib/uuid_singleton for actual UUID generation
 (3) fix event stream use CanvasUUID, rather than following the rename
     of CanvasUuid to CanvasSlug

test-plan:
 - have cassandra set up for audit logs
 - create an audit log entry (e.g. change a grade)
 - look at the generated audit log entry's id field; it should be a UUID
   value, not a 4 character slug

Change-Id: I19758fff4433cd6cb2e21219217dced19ee05c5a
Reviewed-on: https://gerrit.instructure.com/37506
Reviewed-by: Rob Orton <rob@instructure.com>
Tested-by: Jenkins <jenkins@instructure.com>
QA-Review: August Thornton <august@instructure.com>
QA-Review: Jeremy Putnam <jeremyp@instructure.com>
Product-Review: Brian Palmer <brianp@instructure.com>
2014-07-11 16:58:42 +00:00
Jeremy Stanley ecd7c6c7f7 don't add verifiers to locked file links
test plan:
 - have a course with a public syllabus
 - link to two files in the syllabus body:
   - a locked file
   - an unlocked file
 - access the course syllabus without logging in
   - the unlocked file link should work
   - the locked file link should not

fixes CNVS-11569

Change-Id: I75d25a46c7e4fac43c7f187a4aba166be85d1010
Reviewed-on: https://gerrit.instructure.com/31270
Reviewed-by: Bracken Mosbacker <bracken@instructure.com>
Product-Review: Bracken Mosbacker <bracken@instructure.com>
Tested-by: Jenkins <jenkins@instructure.com>
QA-Review: Nathan Rogowski <nathan@instructure.com>
2014-03-05 17:46:31 +00:00
Mark Severson f1365969fb fix wiki links in course copy/migrations
test plan:
 - with draft state enabled
 * create a wiki page
   - use the sidebar to add a link to another wiki page
 * save the page
 * edit the page
   - html view should show the href as ../pages/.. not ../wiki/..
   - copy the link, changing the href to be ../wiki/..
 * save the page
 * copy the course
 * navigate to the copied wiki page
   - both links should point to the page in the new course

fixes CNVS-11443

Change-Id: Ib7f8b175ac6d894a9bfa651f8536b7cd48b60aac
Reviewed-on: https://gerrit.instructure.com/30780
Reviewed-by: Jeremy Stanley <jeremy@instructure.com>
Product-Review: Jeremy Stanley <jeremy@instructure.com>
Tested-by: Jenkins <jenkins@instructure.com>
QA-Review: Matt Fairbourn <mfairbourn@instructure.com>
2014-03-04 00:17:56 +00:00
Joshua Simpson 1e81ea7caa move quiz into quizzes namespace as a precursor to enginifying
fixes CNVS-10679
this commit refactors quiz into a quizzes namespace. it contains various
shims to facilitate the data migration of polymorphic relationships
('Quiz' -> 'Quizzes::Quiz').  JIRA contains several tickets linked to
the above tickets in regards to removing these shims after the data
migration, as well as the strategies on reverting the shims once the
data migration is complete.
Change-Id: I30c566d60a87af6ee83e9d0041fdcb909ead6a89
Reviewed-on: https://gerrit.instructure.com/28573
Tested-by: Jenkins <jenkins@instructure.com>
Reviewed-by: Derek DeVries <ddevries@instructure.com>
QA-Review: Myller de Araujo <myller@instructure.com>
Product-Review: Josh Simpson <jsimpson@instructure.com>
2014-01-24 00:08:46 +00:00
James Williams de56865d66 copy links to wiki pages that start with numbers correctly
fixes a problem where internal links to wiki pages that
had titles that started with numbers would cause the
regular expressions to break

(also fixes a couple random typos and such)

test plan:
* create a wiki page with a title that starts with a
 numeric character
* create a link to that wiki page (such as on another
wiki page)
* copy the course
* the copied course should have a correct link

fixes #CNVS-4158

Change-Id: I8c6a26feb4766e078f06656e7e26f381ae5934d5
Reviewed-on: https://gerrit.instructure.com/18064
Tested-by: Jenkins <jenkins@instructure.com>
Reviewed-by: Jeremy Stanley <jeremy@instructure.com>
QA-Review: Adam Phillipps <adam@instructure.com>
2013-03-15 14:30:58 -06:00