utils

package
v4.10.10+incompatible Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 14, 2019 License: AGPL-3.0, Apache-2.0 Imports: 54 Imported by: 0

Documentation

Index

Constants

View Source
const (
	LOG_ROTATE_SIZE = 10000
	LOG_FILENAME    = "mattermost.log"
)
View Source
const (
	ALPHANUMERIC = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ01234567890"
	LOWERCASE    = "abcdefghijklmnopqrstuvwxyz"
)
View Source
const GIBBERISH_TEXT = `` /* 9068-byte string literal not displayed */

Lovely giberish for all to use

View Source
const (
	INBUCKET_API = "/api/v1/mailbox/"
)
View Source
const (
	TEST_FILE_PATH = "/testfile"
)

Variables

View Source
var AddressForbidden error = errors.New("address forbidden")
View Source
var FUZZY_STRINGS_EMAILS = []string{
	"sue@thatmightbe",
	"sue@thatmightbe.c",
	"sue@thatmightbe.co",
	"su+san@thatmightbe.com",
	"1@2.am",
	"a@b.co.uk",
	"a@b.cancerresearch",
	"su+s+an@thatmightbe.com",
	"per.iod@thatmightbe.com",
}

Strings that should pass as acceptable emails

View Source
var FUZZY_STRINGS_NAMES = []string{
	"*",
	"?",
	".",
	"}{][)(><",
	"{}[]()<>",

	"qahwah ( قهوة)",
	"שָׁלוֹם עֲלֵיכֶם",
	"Ramen チャーシュー chāshū",
	"言而无信",
	"Ṫ͌ó̍ ̍͂̓̍̍̀i̊ͯ͒",
	"&amp; &lt; &qu",

	"' or '1'='1' -- ",
	"' or '1'='1' ({ ",
	"' or '1'='1' /* ",
	"1;DROP TABLE users",

	"<b><i><u><strong><em>",

	"sue@thatmightbe",
	"sue@thatmightbe.",
	"sue@thatmightbe.c",
	"sue@thatmightbe.co",
	"sue @ thatmightbe.com",
	"apos'trophe@thatmightbe.com",
	"apos''''trophe@thatmightbe.com",
	"su+san@thatmightbe.com",
	"su+s+an@thatmightbe.com",
	"per.iod@thatmightbe.com",
	"per..iods@thatmightbe.com",
	".period@thatmightbe.com",
	"tom(comment)@thatmightbe.com",
	"(comment)tom@thatmightbe.com",
	"\"quotes\"@thatmightbe.com",
	"\"\\\"(),:;<>@[\\]\"@thatmightbe.com",
	"a!#$%&'*+-/=?^_`{|}~b@thatmightbe.com",
	"local@[127.0.0.1]",
	"jill@(comment)example.com",
	"jill@example.com(comment)",
	"a@b.中国",
	"1@2.am",
	"a@b.co.uk",
	"a@b.cancerresearch",

	"<a href=\"//www.google.com\">Teh Googles</a>",
	"<img src=\"//upload.wikimedia.org/wikipelogo-v2_2x.png\" />",
	"<b><i><u><strong><em>",
	"&amp; &lt; &quot; &apos;",

	";alert('Well this is awkward.');",
	"<script type='text/javascript'>alert('yay puppies');</script>",

	"Ṫ͌ó̍ ̍͂̓̍̍̀i̊ͯ͒nͧ̍̓̃͋v",
	"H҉̵̞̟̠̖̗̘Ȅ̐̐̑̒̚OMI҉̵̞̟̠",
}

Strings that should pass as acceptable team names

View Source
var FUZZY_STRINGS_POSTS = []string{
	`**[1] - [Markdown Tests]**
_italics_
more _italics_
**bold**
more **bold**
**_bold-italic_**
more **_bold-italic_*8
~~strikethrough~~
more ~~strikethrough~~
` + "```" + `
multi-line code block<enter here>
multi-line code block
emoji that should not render in code block: :ice_cream:
` + "```" + `
` + "`monospace`" + `
[Link to Mattermost](www.mattermost.com)
Inline Image with link, alt text, and hover text: ![Build Status](https://travis-ci.org/mattermost/mattermost-server.svg?branch=master)](https://travis-ci.org/mattermost/mattermost-server)

Three types of lines:
***
___
---
`,

	` **[2] - **[More Markdown Tests]**
> i am a blockquote!

> i am a 2nd multiline 
> quote.
i am text right after a multiline quote, but not in the quote

* list item
* another list item
  * indented list item

1. numbered list, item number 1
2. item number two

`,

	` **[3]** - **[More Markdown Tests]**

Table

| Left-Aligned  | Center Aligned  | Right Aligned |
| :------------ |:---------------:| -----:|
| Left column 1 | this text       |  $100 |
| Left column 2 | is              |   $10 |
| Left column 3 | centered        |    $1 |

Ugly table

Markdown | Less | Pretty
--- | --- | ---
*Still* | ~~renders~~ | **nicely**
1 | 2 | 3

# Large heading
## Smaller heading
### Even smaller heading
# Large heading
## Smaller heading
### Even smaller heading

`,

	` **[4]** - **[More Markdown Tests]**
# This is a heading

I am a multiline
text.

#### I am a level four heading

` + "```tex" + `
f(x) = \int_{-\infty}^\infty
    \hat f(\xi)\,e^{2 \pi i \xi x}
    \,d\xi
` + "```" + `
* This was some tex code*
`,

	`**[5]** - **[Markdown and automatic preview of content test]**

## This should display a preview for the given vine url

Some text *before* the link
And a smiley :)
https://vine.co/v/eDeVgbFrt9L

Some more text here
and here
and even more here
`,

	`**[6]** - **[More markdown and automatic preview of content test]**

## Only the first given url should render an "attachment"

Lets also add a table here, because why not
| Left-Aligned  | Center Aligned  | Right Aligned |
| :------------ |:---------------:| -----:|
| Left column 1 | this text       |  $100 |
| Left column 2 | is              |   $10 |
| Left column 3 | centered        |    $1 |

Wiki should render:
http://en.wikipedia.org/wiki/Foo
https://vine.co/v/eDeVgbFrt9L
`,

	`**[7] [Image Test]**

## this *should* display an image

http://37.media.tumblr.com/tumblr_mavsumGGAd1qboaw8o1_500.jpg
`,

	`**[8] [Emoji Display Test 1]**
:+1: :-1: :100: :1234: :8ball: :a: :ab: :abc: :abcd: :accept: 
:aerial_tramway: :airplane: :alarm_clock: :ambulance: :anchor: :angel: :anger: :angry: :anguished: :ant: 
:apple: :aquarius: :aries: :arrow_backward: :arrow_double_down: :arrow_double_up: :arrow_down: :arrow_down_small: :arrow_forward: :arrow_heading_down:
:arrow_heading_up: :arrow_left: :arrow_lower_left: :arrow_lower_right: :arrow_right: :arrow_right_hook: :arrow_up: :arrow_up_down:
:arrow_upper_left: :arrow_upper_right: :arrows_clockwise: :arrows_counterclockwise: :art: :articulated_lorry: :astonished: :atm:  :arrow_up_small: :b:
:baby: :baby_bottle: :baby_chick: :baby_symbol: :back: :baggage_claim: :balloon: :ballot_box_with_check: :bamboo: :banana:
:bangbang: :bank: :bar_chart: :barber: :baseball: :basketball: :bath: :bathtub: :battery: :bear:
:bee: :beer: :beers: :beetle: :beginner: :bell: :bento: :bicyclist: :bike: :bikini: 
:bird: :birthday: :black_circle: :black_joker: :black_medium_small_square: :black_medium_square: :black_nib: :black_small_square: :black_square: :black_square_button:
:blossom: :blowfish: :blue_book: :blue_car: :blue_heart: :blush: :boar: :boat: :bomb: :book:
:bookmark: :bookmark_tabs: :books: :boom: :boot: :bouquet: :bow: :bowling: :bowtie: :boy:
:bread: :bride_with_veil: :bridge_at_night: :briefcase: :broken_heart: :bug: :bulb: :bullettrain_front: :bullettrain_side: :bus: 
:busstop: :bust_in_silhouette: :busts_in_silhouette: :cactus: :cake: :calendar: :calling: :camel: :camera: :cancer: 
:candy: :capital_abcd: :capricorn: :car: :card_index: :carousel_horse: :cat: :cat2: :cd: :chart: 
:chart_with_downwards_trend: :chart_with_upwards_trend: :checkered_flag: :cherries: :cherry_blossom: :chestnut: :chicken: :children_crossing: :chocolate_bar: :christmas_tree:
:church: :cinema: :circus_tent: :city_sunrise: :city_sunset: :cl: :clap: :clapper: :clipboard: :clock1: 
:clock10: :clock1030: :clock11: :clock1130: :clock12: :clock1230: :clock130: :clock2: :clock230: :clock3: 
:clock330: :clock4: :clock430: :clock5: :clock530: :clock6: :clock630: :clock7: :clock730: :clock8: 
:clock830: :clock9: :clock930: :closed_book: :closed_lock_with_key: :closed_umbrella: :cloud: :clubs: :cn: :cocktail:
:coffee: :cold_sweat: :collision: :computer: :confetti_ball: :confounded: :confused: :congratulations: :construction: :construction_worker:
:convenience_store: :cookie: :cool: :cop: :copyright: :corn: :couple: :couple_with_heart: :couplekiss: :cow:
:cow2: :credit_card: :crescent_moon: :crocodile: :crossed_flags: :crown: :cry: :crying_cat_face: :crystal_ball: :cupid: 
:curly_loop: :currency_exchange: :curry: :custard: :customs: :cyclone: :dancer: :dancers: :dango: :dart:
:dash: :date: :de: :deciduous_tree: :department_store: :diamond_shape_with_a_dot_inside: :diamonds: :disappointed: :disappointed_relieved: :dizzy:
:dizzy_face: :do_not_litter: :dog: :dog2: :dollar: :dolls: :dolphin: :donut: :door: :doughnut:
:dragon: :dragon_face: :dress: :dromedary_camel: :droplet: :dvd: :e-mail: :ear: :ear_of_rice: :earth_africa: 
:earth_americas: :earth_asia: :egg: :eggplant: :eight: :eight_pointed_black_star: :eight_spoked_asterisk: :electric_plug: :elephant: :email: 
 :end: :envelope: :es: :euro: :european_castle: :european_post_office: :evergreen_tree: :exclamation: :expressionless: :eyeglasses: 
:eyes: :facepunch: :factory: :fallen_leaf: :family: :fast_forward: :fax: :fearful: :feelsgood: :feet: 
:ferris_wheel: :file_folder: :finnadie: :fire: :fire_engine: :fireworks: :first_quarter_moon: :first_quarter_moon_with_face: :fish: :fish_cake:
:fishing_pole_and_fish: :fist: :five: :flags: :flashlight: :floppy_disk: :flower_playing_cards: :flushed: :foggy: :football:
:fork_and_knife: :fountain: :four: :four_leaf_clover: :fr: :free: :fried_shrimp: :fries: :frog: :frowning:
:fu: :fuelpump: :full_moon: :full_moon_with_face: :game_die: :gb: :gem: :gemini: :ghost: :gift:`,

	`**[9] [Emoji Display Test 2]**
:gift_heart: :girl: :globe_with_meridians: :goat: :goberserk: :godmode: :golf: :grapes: :green_apple: :green_book:
:green_heart: :grey_exclamation: :grey_question: :grimacing: :grin: :grinning: :guardsman: :guitar: :gun: :haircut: 
:hamburger: :hammer: :hamster: :hand: :handbag: :hankey: :hash: :hatched_chick: :hatching_chick: :headphones:
:hear_no_evil: :heart: :heart_decoration: :heart_eyes: :heart_eyes_cat: :heartbeat: :heartpulse: :hearts: :heavy_check_mark: :heavy_division_sign:
:heavy_dollar_sign: :heavy_exclamation_mark: :heavy_minus_sign: :heavy_multiplication_x: :heavy_plus_sign: :helicopter: :herb: :hibiscus: :high_brightness: :high_heel:
:hocho: :honey_pot: :honeybee: :horse: :horse_racing: :hospital: :hotel: :hotsprings: :hourglass: :hourglass_flowing_sand:
:house: :house_with_garden: :hurtrealbad: :hushed: :ice_cream: :icecream: :id: :ideograph_advantage: :imp: :inbox_tray: 
:incoming_envelope: :information_desk_person: :information_source: :innocent: :interrobang: :iphone: :it: :izakaya_lantern: :jack_o_lantern:
:japan: :japanese_castle: :japanese_goblin: :japanese_ogre: :jeans: :joy: :joy_cat: :jp: :key: :keycap_ten:
:kimono: :kiss: :kissing: :kissing_cat: :kissing_closed_eyes: :kissing_face: :kissing_heart: :kissing_smiling_eyes: :koala: :koko:
:kr: :large_blue_circle: :large_blue_diamond: :large_orange_diamond: :last_quarter_moon: :last_quarter_moon_with_face: :laughing: :leaves: :ledger: :left_luggage:
:left_right_arrow: :leftwards_arrow_with_hook: :lemon: :leo: :leopard: :libra: :light_rail: :link: :lips: :lipstick:
:lock: :lock_with_ink_pen: :lollipop: :loop: :loudspeaker: :love_hotel: :love_letter: :low_brightness: :m: :mag:
:mag_right: :mahjong: :mailbox: :mailbox_closed: :mailbox_with_mail: :mailbox_with_no_mail: :man: :man_with_gua_pi_mao: :man_with_turban: :mans_shoe:
:maple_leaf: :mask: :massage: :meat_on_bone: :mega: :melon: :memo: :mens: :metal: :metro:
:microphone: :microscope: :milky_way: :minibus: :minidisc: :mobile_phone_off: :money_with_wings: :moneybag: :monkey: :monkey_face: 
:monorail: :mortar_board: :mount_fuji: :mountain_bicyclist: :mountain_cableway: :mountain_railway: :mouse: :mouse2: :movie_camera: :moyai:
:muscle: :mushroom: :musical_keyboard: :musical_note: :musical_score: :mute: :nail_care: :name_badge: :neckbeard: :necktie:
:negative_squared_cross_mark: :neutral_face: :new: :new_moon: :new_moon_with_face: :newspaper: :ng: :nine: :no_bell:
:no_bicycles: :no_entry: :no_entry_sign: :no_good: :no_mobile_phones: :no_mouth: :no_pedestrians: :no_smoking: :non-potable_water: :nose:
:notebook: :notebook_with_decorative_cover: :notes: :nut_and_bolt: :o: :o2: :ocean: :octocat: :octopus: :oden: 
:office: :ok: :ok_hand: :ok_woman: :older_man: :older_woman: :on: :oncoming_automobile: :oncoming_bus: :oncoming_police_car:
:oncoming_taxi: :one: :open_file_folder: :open_hands: :open_mouth: :ophiuchus: :orange_book: :outbox_tray: :ox: :package:
:page_facing_up: :page_with_curl: :pager: :palm_tree: :panda_face: :paperclip: :parking: :part_alternation_mark: :partly_sunny: :passport_control:
:paw_prints: :peach: :pear: :pencil: :pencil2: :penguin: :pensive: :performing_arts: :persevere: :person_frowning:
:person_with_blond_hair: :person_with_pouting_face: :phone: :pig: :pig2: :pig_nose: :pill: :pineapple: :pisces: :pizza:
`,

	`**[10] [Emoji Display Test 3]**
:plus1: :point_down: :point_left: :point_right: :point_up: :point_up_2: :police_car: :poodle: :poop: :post_office:
:postal_horn: :postbox: :potable_water: :pouch: :poultry_leg: :pound: :pouting_cat: :pray: :princess: :punch: 
:purple_heart: :purse: :pushpin: :put_litter_in_its_place: :question: :rabbit: :rabbit2: :racehorse: :radio: :radio_button:
:rage: :rage1: :rage2: :rage3: :rage4: :railway_car: :rainbow: :raised_hand: :raised_hands: :raising_hand:
:ram: :ramen: :rat: :recycle: :red_car: :red_circle: :registered: :relaxed: :relieved: :repeat: 
:repeat_one: :restroom: :revolving_hearts: :rewind: :ribbon: :rice: :rice_ball: :rice_cracker: :rice_scene: :ring: 
:rocket: :roller_coaster: :rooster: :rose: :rotating_light: :round_pushpin: :rowboat: :ru:
:rugby_football: :runner: :running: :running_shirt_with_sash: :sa: :sagittarius: :sailboat: :sake: :sandal: :santa: 
:satellite: :satisfied: :saxophone: :school: :school_satchel: :scissors: :scorpius: :scream: :scream_cat: :scroll:
:seat: :secret: :see_no_evil: :seedling: :seven: :shaved_ice: :sheep: :shell: :ship: :shipit:
:shirt: :shit: :shoe: :shower: :signal_strength: :six: :six_pointed_star: :ski: :skull: :sleeping:
:sleepy: :slot_machine: :small_blue_diamond: :small_orange_diamond: :small_red_triangle: :small_red_triangle_down: :smile: :smile_cat: :smiley: :smiley_cat:
:smiling_imp: :smirk: :smirk_cat: :smoking: :snail: :snake: :snowboarder: :snowflake: :snowman: :sob:
:soccer: :soon: :sos: :sound: :space_invader: :spades: :spaghetti: :sparkle: :sparkler: :sparkles:
:sparkling_heart: :speak_no_evil: :speaker: :speech_balloon: :speedboat: :squirrel: :star: :star2: :stars: :station:
:statue_of_liberty: :steam_locomotive: :stew: :straight_ruler: :strawberry: :stuck_out_tongue: :stuck_out_tongue_closed_eyes: :stuck_out_tongue_winking_eye: :sun_with_face: :sunflower:
 :sunglasses: :sunny: :sunrise: :sunrise_over_mountains: :surfer: :sushi: :suspect: :suspension_railway: :sweat: :sweat_drops:
:sweat_smile: :sweet_potato: :swimmer: :symbols: :syringe: :tada: :tanabata_tree: :tangerine: :taurus: :taxi:
:tea: :telephone: :telephone_receiver: :telescope: :tennis: :tent: :thought_balloon: :three: :thumbsdown: :thumbsup: 
:ticket: :tiger: :tiger2: :tired_face: :tm: :toilet: :tokyo_tower: :tomato: :tongue: :top:
:tophat: :tractor: :traffic_light: :train: :train2: :tram: :triangular_flag_on_post: :triangular_ruler: :trident: :triumph:
:trolleybus: :trollface: :trophy: :tropical_drink: :tropical_fish: :truck: :trumpet: :tshirt: :tulip: :turtle: 
:tv: :twisted_rightwards_arrows: :two: :two_hearts: :two_men_holding_hands: :two_women_holding_hands: 
:uk: :umbrella: :unamused: :underage: :unlock: :up: :us: :v: :vertical_traffic_light: :vhs: 
:vibration_mode: :video_camera: :video_game: :violin: :virgo: :volcano: :vs: :walking: :waning_crescent_moon: :waning_gibbous_moon:
:warning: :watch: :water_buffalo: :watermelon: :wave: :wavy_dash: :waxing_crescent_moon: :waxing_gibbous_moon: :wc: :weary:
:wedding: :whale: :whale2: :wheelchair: :white_check_mark: :white_circle: :white_flower: :white_large_square: :white_medium_small_square:  :white_medium_square:
:white_small_square: :white_square_button: :wind_chime: :wine_glass: :wink: :wolf: :woman: :womans_clothes: :womans_hat: :womens:
:worried: :wrench: :x: :yellow_heart: :yen: :yum: :zap: :zero: :zzz:
Unnamed: :u5272: :u5408: :u55b6: :u6307: :u6708: :u6709: :u6e80: :u7121: :u7533: :u7981: :u7a7a:
`,

	`**[11] [Auto Linking]**
#### should be turned into links:
http://example.com
https://example.com
www.example.com
www.example.com/index
www.example.com/index.html
www.example.com/index/sub
www.example.com/index?params=1
www.example.com/index?params=1&other=2
www.example.com/index?params=1;other=2
http://example.com:8065
<http://example.com>
<www.example.com>
http://www.example.com/_/page
www.example.com/_/page
https://en.wikipedia.org/wiki/🐬
https://en.wikipedia.org/wiki/Rendering_(computer_graphics)
http://127.0.0.1
http://192.168.1.1:4040
http://[::1]:80
http://[::1]:8065
https://[::1]:80
http://[2001:0:5ef5:79fb:303a:62d5:3312:ff42]:80
http://[2001:0:5ef5:79fb:303a:62d5:3312:ff42]:8065
https://[2001:0:5ef5:79fb:303a:62d5:3312:ff42]:443
http://username:password@example.com
http://username:password@127.0.0.1
http://username:password@[2001:0:5ef5:79fb:303a:62d5:3312:ff42]:80
test@example.com

#### should be turned into links which link to the correct place:
[example link](example.com) links to ` + "`" + `http://example.com` + "`" + `
[example.com](example.com) links to ` + "`" + `http://example.com` + "`" + `
[example.com/other](example.com) links to ` + "`" + `http://example.com` + "`" + `
[example.com/other_link](example.com/example) links to ` + "`" + `http://example.com/example` + "`" + `
www.example.com links to ` + "`" + `http://www.example.com` + "`" + `
https://example.com links to ` + "`" + `https://example.com` + "`" + `and not ` + "`" + `http://example.com` + "`" + `
https://en.wikipedia.org/wiki/🐬 links to the Wikipedia article on dolphins
https://en.wikipedia.org/wiki/URLs#Syntax links to the Syntax section of the Wikipedia article on URLs
test@example.com links to ` + "`" + `mailto:test@example.com` + "`" + `
[email link](mailto:test@example.com) links to ` + "`" + `mailto:test@example.com` + "`" + `and not ` + "`" + `http://mailto:test@example.com` + "`" + `
[other link](ts3server://example.com) links to ` + "`" + `ts3server://example.com` + "`" + `and not ` + "`" + `http://ts3server://example.com` + "`" + `

#### should not be turned into links:
example.com
readme.md
<example.com>
http://
@example.com

#### should only turn the actual link into a link and not change surrounding text
(http://example.com)
(test@example.com)
This is a sentence with a http://example.com in it.
This is a sentence with a [link](http://example.com) in it.
This is a sentence with a http://example.com/_/underscore in it.
This is a sentence with a link (http://example.com) in it.
This is a sentence with a (https://en.wikipedia.org/wiki/Rendering_(computer_graphics)) in it.
This is a sentence with a http://192.168.1.1:4040 in it.
This is a sentence with a https://::1 in it.
This is a link to http://example.com.
`,

	"*", "?", ".", "}{][)(><", "{}[]()<>",

	"qahwah ( قهوة)",
	"שָׁלוֹם עֲלֵיכֶם",
	"Ramen チャーシュー chāshū",
	"言而无信",
	"Ṫ͌ó̍ ̍͂̓̍̍̀i̊ͯ͒",
	"&amp; &lt; &qu",

	"' or '1'='1' -- ",
	"' or '1'='1' ({ ",
	"' or '1'='1' /* ",
	"1;DROP TABLE users",

	"<b><i><u><strong><em>",

	"sue@thatmightbe",
	"sue@thatmightbe.",
	"sue@thatmightbe.c",
	"sue@thatmightbe.co",
	"su+san@thatmightbe.com",
	"a@b.中国",
	"1@2.am",
	"a@b.co.uk",
	"a@b.cancerresearch",
	"local@[127.0.0.1]",

	"!@$%^&:*.,/|;'\"+=?`~#",
	"'\"/\\\"\"''\\/",
	"gggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggg",
	"gggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggg",
	"ą ć ę ł ń ó ś ź ż č ď ě ň ř š ť ž ă î ø å æ á é í ó ú Ç Ğ İ Ö Ş Ü",
	"abcdefghijklmnopqrstuvwrxyz0123456789 -_",
	"Ṫ͌ó̍ ̍͂̓̍̍̀i̊ͯ͒nͧ̍̓̃͋vok̂̓ͤ̓̂ěͬ ͆tͬ̐́̐͆h̒̏͌̓e͂ ̎̊h̽͆ͯ̄ͮi͊̂ͧͫ̇̃vͥͦ́ẻͤ-͒m̈́̀i̓ͮ͗̑͌̆̅n̓̓ͨd̊̑͛̔̚ ͨͮ̊̾rͪeͭͭ͑ͧ́͋p̈́̅̚rͧe̒̈̌s̍̽ͩ̓̇e͗n̏͊ͬͭtͨ͆ͤ̚iͪ͗̍n͐͒g̾ͦ̎ ͥ͌̽̊ͩͥ͗c̀ͬͣha̍̏̉ͪ̈̚o̊̏s̊̋̀̏̽̚.͒ͫ͛͛̎ͥ",
	"H҉̵̞̟̠̖̗̘Ȅ̐̑̒̚̕̚ IS C̒̓̔̿̿̿̕̚̚̕̚̕̚̕̚̕̚̕̚OMI҉̵̞̟̠̖̗̘NG > ͡҉҉ ̵̡̢̛̗̘̙̜̝̞̟̠͇̊̋̌̍̎̏̿̿̿̚ ҉ ҉҉̡̢̡̢̛̛̖̗̘̙̜̝̞̟̠̖̗̘̙̜̝̞̟̠̊̋̌̍̎̏̐̑̒̓̔̊̋̌̍̎̏̐̑ ͡҉҉",

	"<a href=\"//www.google.com\">Teh Googles</a>",
	"<img src=\"//upload.wikimedia.org/wikipedia/meta/b/be/Wikipedia-logo-v2_2x.png\" />",
	"&amp; &lt; &quot; &apos;",
	" %21 %23 %24 %26 %27 %28 %29 %2A	%2B	%2C	%2F	%3A	%3B	%3D	%3F	%40	%5B	%5D %0D %0A %0D%0A %20 %22 %25 %2D %2E %3C %3E %5C %5E %5F %60 %7B %7C %7D %7E",

	";alert('Well this is awkward.');",
	"<script type='text/javascript'>alert('yay puppies');</script>",

	"http?q=foobar%0d%0aContent-\nLength:%200%0d%0a%0d%0aHTTP/1.1%20200%20OK%0d%0aContent-\nType:%20text/html%0d%0aContent-Length:%2019%0d%0a%0d%0a<html>Shazam</html>",

	"apos'trophe@thatmightbe.com",
	"apos''''trophe@thatmightbe.com",
	"su+s+an@thatmightbe.com",
	"per.iod@thatmightbe.com",
	"per..iods@thatmightbe.com",
	".period@thatmightbe.com",
	"tom(comment)@thatmightbe.com",
	"(comment)tom@thatmightbe.com",
	"\"quotes\"@thatmightbe.com",
	"\"\\\"(),:;<>@[\\]\"@thatmightbe.com",
	"a!#$%&'*+-/=?^_`{|}~b@thatmightbe.com",
	"jill@(comment)example.com",
	"jill@example.com(comment)",
	"ben@ggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggg.com",
	"judy@gggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggg.com",
	"ggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggg@AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA.com",
}

Strings that should pass as acceptable posts

Functions

func CheckMandatoryS3Fields

func CheckMandatoryS3Fields(settings *model.FileSettings) *model.AppError

func CheckOrigin

func CheckOrigin(r *http.Request, allowedOrigins string) bool

func ConnectToSMTPServer

func ConnectToSMTPServer(config *model.Config) (net.Conn, *model.AppError)

func ConnectToSMTPServerAdvanced

func ConnectToSMTPServerAdvanced(connectionInfo *SmtpConnectionInfo) (net.Conn, *model.AppError)

func CopyDir

func CopyDir(src string, dst string) (err error)

CopyDir will copy a directory and all contained files and directories. src must exist and dst must not exist. Permissions are preserved when possible. Symlinks are skipped.

func CopyFile

func CopyFile(src, dst string) (err error)

CopyFile will copy a file from src path to dst path. Overwrites any existing files at dst. Permissions are copied from file at src to the new file at dst.

func CreateTestAnimatedGif

func CreateTestAnimatedGif(t *testing.T, width int, height int, frames int) []byte

func CreateTestGif

func CreateTestGif(t *testing.T, width int, height int) []byte

func CreateTestJpeg

func CreateTestJpeg(t *testing.T, width int, height int) []byte

func CreateTestPng

func CreateTestPng(t *testing.T, width int, height int) []byte

func DeleteMailBox

func DeleteMailBox(email string) (err error)

func DisableDebugLogForTest

func DisableDebugLogForTest()

DON'T USE THIS Modify the level on the app logger

func EnableDebugLogForTest

func EnableDebugLogForTest()

DON'T USE THIS Modify the level on the app logger

func EndOfDay added in v1.3.0

func EndOfDay(t time.Time) time.Time

func EnsureConfigFile

func EnsureConfigFile(fileName string) (string, error)

EnsureConfigFile will attempt to locate a config file with the given name. If it does not exist, it will attempt to locate a default config file, and copy it to a file named fileName in the same directory. In either case, the config file path is returned.

func ExtractTarGz

func ExtractTarGz(gzipStream io.Reader, dst string) error

ExtractTarGz takes in an io.Reader containing the bytes for a .tar.gz file and a destination string to extract to.

func FileExistsInConfigFolder

func FileExistsInConfigFolder(filename string) bool

func FindConfigFile

func FindConfigFile(fileName string) (path string)

FindConfigFile attempts to find an existing configuration file. fileName can be an absolute or relative path or name such as "/opt/mattermost/config.json" or simply "config.json". An empty string is returned if no configuration is found.

func FindDir

func FindDir(dir string) (string, bool)

FindDir looks for the given directory in nearby ancestors, falling back to `./` if not found.

func FuzzName

func FuzzName() string

func FuzzPost

func FuzzPost() string

func GenerateClientConfig

func GenerateClientConfig(c *model.Config, diagnosticId string, license *model.License) map[string]string

func GetAndValidateLicenseFileFromDisk

func GetAndValidateLicenseFileFromDisk(location string) (*model.License, []byte)

func GetClientLicense

func GetClientLicense(l *model.License) map[string]string

func GetHostnameFromSiteURL

func GetHostnameFromSiteURL(siteURL string) string

func GetIpAddress

func GetIpAddress(r *http.Request) string

func GetLicenseFileFromDisk

func GetLicenseFileFromDisk(fileName string) []byte

func GetLicenseFileLocation

func GetLicenseFileLocation(fileLocation string) string

func GetLogFileLocation

func GetLogFileLocation(fileLocation string) string

func GetSupportedLocales

func GetSupportedLocales() map[string]string

func GetTranslationsAndLocale

func GetTranslationsAndLocale(w http.ResponseWriter, r *http.Request) (i18n.TranslateFunc, string)

func GetTranslationsBySystemLocale

func GetTranslationsBySystemLocale() (i18n.TranslateFunc, error)

func GetUserTranslations

func GetUserTranslations(locale string) i18n.TranslateFunc

func HashSha256

func HashSha256(text string) string

func InitTranslations

func InitTranslations(localizationSettings model.LocalizationSettings) error

func InitTranslationsWithDir

func InitTranslationsWithDir(dir string) error

func IsOwnIP

func IsOwnIP(ip net.IP) (bool, error)

IsOwnIP handles the special case that a request might be made to the public IP of the host which on Linux is routed directly via the loopback IP to any listening sockets, effectively bypassing host-based firewalls such as firewalld

func IsPasswordValid

func IsPasswordValid(password string) *model.AppError

func IsPasswordValidWithSettings

func IsPasswordValidWithSettings(password string, settings *model.PasswordSettings) *model.AppError

func IsReservedIP

func IsReservedIP(ip net.IP) bool

IsReservedIP checks whether the target IP belongs to reserved IP address ranges to avoid SSRF attacks to the internal network of the Mattermost server

func LoadConfig

func LoadConfig(fileName string) (*model.Config, string, map[string]interface{}, *model.AppError)

LoadConfig will try to search around for the corresponding config file. It will search /tmp/fileName then attempt ./config/fileName, then ../config/fileName and last it will look at fileName.

func LoadTimezones

func LoadTimezones(fileName string) model.SupportedTimezones

func LoginAuth

func LoginAuth(username, password, host string) smtp.Auth

func MillisFromTime added in v1.3.0

func MillisFromTime(t time.Time) int64

func MloggerConfigFromLoggerConfig

func MloggerConfigFromLoggerConfig(s *model.LogSettings) *mlog.LoggerConfiguration

func NewHTTPClient

func NewHTTPClient(enableInsecureConnections bool, allowHost func(host string) bool, allowIP func(ip net.IP) bool) *http.Client

NewHTTPClient returns a variation the default implementation of Client. It uses a Transport with the same settings as the default Transport but with the following modifications:

  • shorter timeout for dial and TLS handshake (defined as constant "connectTimeout")
  • timeout for the end-to-end request (defined as constant "requestTimeout")

func NewSMTPClient

func NewSMTPClient(conn net.Conn, config *model.Config) (*smtp.Client, *model.AppError)

func NewSMTPClientAdvanced

func NewSMTPClientAdvanced(conn net.Conn, hostname string, connectionInfo *SmtpConnectionInfo) (*smtp.Client, *model.AppError)

func OriginChecker

func OriginChecker(allowedOrigins string) func(*http.Request) bool

func ParseEmail

func ParseEmail(email string) string

func PathTraversesUpward

func PathTraversesUpward(path string) bool

PathTraversesUpward will return true if the path attempts to traverse upwards by using ".." in the path.

func RandIntFromRange

func RandIntFromRange(r Range) int

func RandString

func RandString(l int, charset string) string

func RandomName

func RandomName(length Range, charset string) string

func RandomText

func RandomText(length Range, hashtags Range, mentions Range, users []string) string

Random selection of text for post

func ReadConfig

func ReadConfig(r io.Reader, allowEnvironmentOverrides bool) (*model.Config, map[string]interface{}, error)

ReadConfig reads and parses the given configuration.

func ReadConfigFile

func ReadConfigFile(path string, allowEnvironmentOverrides bool) (*model.Config, map[string]interface{}, error)

ReadConfigFile reads and parses the configuration at the given file path.

func RemoveDuplicatesFromStringArray

func RemoveDuplicatesFromStringArray(arr []string) []string

func RenderWebAppError

func RenderWebAppError(w http.ResponseWriter, r *http.Request, err *model.AppError, s crypto.Signer)

func RenderWebError

func RenderWebError(w http.ResponseWriter, r *http.Request, status int, params url.Values, s crypto.Signer)

func RetryInbucket

func RetryInbucket(attempts int, callback func() error) (err error)

func SaveConfig

func SaveConfig(fileName string, config *model.Config) *model.AppError

func SendMail

func SendMail(c *smtp.Client, mimeTo, smtpTo string, from mail.Address, subject, htmlBody string, attachments []*model.FileInfo, mimeHeaders map[string]string, fileBackend FileBackend, date time.Time) *model.AppError

func SendMailUsingConfig

func SendMailUsingConfig(to, subject, htmlBody string, config *model.Config, enableComplianceFeatures bool) *model.AppError

func SendMailUsingConfigAdvanced

func SendMailUsingConfigAdvanced(mimeTo, smtpTo string, from mail.Address, subject, htmlBody string, attachments []*model.FileInfo, mimeHeaders map[string]string, config *model.Config, enableComplianceFeatures bool) *model.AppError

allows for sending an email with attachments and differing MIME/SMTP recipients

func SetRolePermissionsFromConfig

func SetRolePermissionsFromConfig(roles map[string]*model.Role, cfg *model.Config, isLicensed bool) map[string]*model.Role

func StartOfDay added in v1.3.0

func StartOfDay(t time.Time) time.Time

func StringArrayIntersection

func StringArrayIntersection(arr1, arr2 []string) []string

func StringInSlice

func StringInSlice(a string, slice []string) bool

func TestConnection added in v1.1.0

func TestConnection(config *model.Config)

func TfuncWithFallback

func TfuncWithFallback(pref string) i18n.TranslateFunc

func TimeFromMillis

func TimeFromMillis(millis int64) time.Time

func TranslateAsHtml

func TranslateAsHtml(t i18n.TranslateFunc, translationID string, args map[string]interface{}) template.HTML

func TranslationsPreInit

func TranslationsPreInit() error

this functions loads translations from filesystem and assign english while loading server config

func UrlEncode

func UrlEncode(str string) string

func ValidateLdapFilter

func ValidateLdapFilter(cfg *model.Config, ldap einterfaces.LdapInterface) *model.AppError

func ValidateLicense

func ValidateLicense(signed []byte) (bool, string)

func ValidateLocales

func ValidateLocales(cfg *model.Config) *model.AppError

func Yesterday added in v1.3.0

func Yesterday() time.Time

Types

type Cache

type Cache struct {
	// contains filtered or unexported fields
}

Cache is a thread-safe fixed size LRU cache.

func NewLru

func NewLru(size int) *Cache

New creates an LRU of the given size

func NewLruWithParams

func NewLruWithParams(size int, name string, defaultExpiry int64, invalidateClusterEvent string) *Cache

func (*Cache) Add

func (c *Cache) Add(key, value interface{})

func (*Cache) AddWithDefaultExpires

func (c *Cache) AddWithDefaultExpires(key, value interface{})

func (*Cache) AddWithExpiresInSecs

func (c *Cache) AddWithExpiresInSecs(key, value interface{}, expireAtSecs int64)

func (*Cache) Get

func (c *Cache) Get(key interface{}) (value interface{}, ok bool)

func (*Cache) GetInvalidateClusterEvent

func (c *Cache) GetInvalidateClusterEvent() string

func (*Cache) Keys

func (c *Cache) Keys() []interface{}

Keys returns a slice of the keys in the cache, from oldest to newest.

func (*Cache) Len

func (c *Cache) Len() int

Len returns the number of items in the cache.

func (*Cache) Name

func (c *Cache) Name() string

func (*Cache) Purge

func (c *Cache) Purge()

Purge is used to completely clear the cache

func (*Cache) Remove

func (c *Cache) Remove(key interface{})

type ConfigWatcher

type ConfigWatcher struct {
	// contains filtered or unexported fields
}

func NewConfigWatcher

func NewConfigWatcher(cfgFileName string, f func()) (*ConfigWatcher, error)

func (*ConfigWatcher) Close

func (w *ConfigWatcher) Close()

type DialContextFunction

type DialContextFunction func(ctx context.Context, network, addr string) (net.Conn, error)

type FileBackend

type FileBackend interface {
	TestConnection() *model.AppError

	ReadFile(path string) ([]byte, *model.AppError)
	CopyFile(oldPath, newPath string) *model.AppError
	MoveFile(oldPath, newPath string) *model.AppError
	WriteFile(f []byte, path string) *model.AppError
	RemoveFile(path string) *model.AppError

	ListDirectory(path string) (*[]string, *model.AppError)
	RemoveDirectory(path string) *model.AppError
}

func NewFileBackend

func NewFileBackend(settings *model.FileSettings, enableComplianceFeatures bool) (FileBackend, *model.AppError)

type HTMLTemplate

type HTMLTemplate struct {
	Templates    *template.Template
	TemplateName string
	Props        map[string]interface{}
	Html         map[string]template.HTML
}

func NewHTMLTemplate

func NewHTMLTemplate(templates *template.Template, templateName string) *HTMLTemplate

func (*HTMLTemplate) Render

func (t *HTMLTemplate) Render() string

func (*HTMLTemplate) RenderToWriter

func (t *HTMLTemplate) RenderToWriter(w io.Writer) error

type HTMLTemplateWatcher

type HTMLTemplateWatcher struct {
	// contains filtered or unexported fields
}

func NewHTMLTemplateWatcher

func NewHTMLTemplateWatcher(directory string) (*HTMLTemplateWatcher, error)

func (*HTMLTemplateWatcher) Close

func (w *HTMLTemplateWatcher) Close()

func (*HTMLTemplateWatcher) Templates

func (w *HTMLTemplateWatcher) Templates() *template.Template

type JSONMessageHeaderInbucket

type JSONMessageHeaderInbucket []struct {
	Mailbox             string
	ID                  string `json:"Id"`
	From, Subject, Date string
	To                  []string
	Size                int
}

OutputJSONHeader holds the received Header to test sending emails (inbucket)

func GetMailBox

func GetMailBox(email string) (results JSONMessageHeaderInbucket, err error)

type JSONMessageInbucket

type JSONMessageInbucket struct {
	Mailbox             string
	ID                  string `json:"Id"`
	From, Subject, Date string
	Size                int
	Header              map[string][]string
	Body                struct {
		Text string
		HTML string `json:"Html"`
	}
	Attachments []struct {
		Filename     string
		ContentType  string `json:"content-type"`
		DownloadLink string `json:"download-link"`
		Bytes        []byte `json:"-"`
	}
}

OutputJSONMessage holds the received Message fto test sending emails (inbucket)

func GetMessageFromMailbox

func GetMessageFromMailbox(email, id string) (results JSONMessageInbucket, err error)

type LocalFileBackend

type LocalFileBackend struct {
	// contains filtered or unexported fields
}

func (*LocalFileBackend) CopyFile

func (b *LocalFileBackend) CopyFile(oldPath, newPath string) *model.AppError

func (*LocalFileBackend) ListDirectory

func (b *LocalFileBackend) ListDirectory(path string) (*[]string, *model.AppError)

func (*LocalFileBackend) MoveFile

func (b *LocalFileBackend) MoveFile(oldPath, newPath string) *model.AppError

func (*LocalFileBackend) ReadFile

func (b *LocalFileBackend) ReadFile(path string) ([]byte, *model.AppError)

func (*LocalFileBackend) RemoveDirectory

func (b *LocalFileBackend) RemoveDirectory(path string) *model.AppError

func (*LocalFileBackend) RemoveFile

func (b *LocalFileBackend) RemoveFile(path string) *model.AppError

func (*LocalFileBackend) TestConnection

func (b *LocalFileBackend) TestConnection() *model.AppError

func (*LocalFileBackend) WriteFile

func (b *LocalFileBackend) WriteFile(f []byte, path string) *model.AppError

type ObjectCache

type ObjectCache interface {
	AddWithExpiresInSecs(key, value interface{}, expireAtSecs int64)
	AddWithDefaultExpires(key, value interface{})
	Purge()
	Get(key interface{}) (value interface{}, ok bool)
	Remove(key interface{})
	Len() int
	Name() string
	GetInvalidateClusterEvent() string
}

Caching Interface

type Range

type Range struct {
	Begin int
	End   int
}

type S3FileBackend

type S3FileBackend struct {
	// contains filtered or unexported fields
}

func (*S3FileBackend) CopyFile

func (b *S3FileBackend) CopyFile(oldPath, newPath string) *model.AppError

func (*S3FileBackend) ListDirectory

func (b *S3FileBackend) ListDirectory(path string) (*[]string, *model.AppError)

func (*S3FileBackend) MoveFile

func (b *S3FileBackend) MoveFile(oldPath, newPath string) *model.AppError

func (*S3FileBackend) ReadFile

func (b *S3FileBackend) ReadFile(path string) ([]byte, *model.AppError)

func (*S3FileBackend) RemoveDirectory

func (b *S3FileBackend) RemoveDirectory(path string) *model.AppError

func (*S3FileBackend) RemoveFile

func (b *S3FileBackend) RemoveFile(path string) *model.AppError

func (*S3FileBackend) TestConnection

func (b *S3FileBackend) TestConnection() *model.AppError

func (*S3FileBackend) WriteFile

func (b *S3FileBackend) WriteFile(f []byte, path string) *model.AppError

type SmtpConnectionInfo

type SmtpConnectionInfo struct {
	SmtpUsername         string
	SmtpPassword         string
	SmtpServerName       string
	SmtpServerHost       string
	SmtpPort             string
	SkipCertVerification bool
	ConnectionSecurity   string
	Auth                 bool
}

Directories

Path Synopsis
This package implements a parser for the subset of the CommonMark spec necessary for us to do server-side processing.
This package implements a parser for the subset of the CommonMark spec necessary for us to do server-side processing.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL