Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[ci][webui] Fix presentation of package file names in webui
We have a package helper that replaces whitespaces in package names with nbsp. We also add wbr tags to long file names. With recent OBS html sanitization this broke. This commit fixes it.
- Loading branch information
Showing
3 changed files
with
37 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
require 'test_helper' | ||
|
||
class Webui::PackageHelperTest < ActiveSupport::TestCase | ||
include Webui::PackageHelper | ||
|
||
def test_nbsp | ||
assert nbsp("a").is_a?(ActiveSupport::SafeBuffer) | ||
|
||
sanitized_string = nbsp("<b>unsafe<b/>") | ||
assert_equal "<b>unsafe<b/>", sanitized_string | ||
assert sanitized_string.is_a?(ActiveSupport::SafeBuffer) | ||
|
||
sanitized_string = nbsp("my file") | ||
assert_equal "my file", sanitized_string | ||
assert sanitized_string.is_a?(ActiveSupport::SafeBuffer) | ||
|
||
long_file_name = "a"*50 + "b"*50 + "c"*10 | ||
sanitized_string = nbsp(long_file_name) | ||
assert_equal long_file_name.scan(/.{1,50}/).join("<wbr>"), sanitized_string | ||
assert sanitized_string.is_a?(ActiveSupport::SafeBuffer) | ||
end | ||
end |