Recent from talks
Nothing was collected or created yet.
View-source URI scheme
View on WikipediaThe view-source URI scheme is used by some web browsers to construct URIs that result in the browser displaying the source code of a web page or other web resource.[1]
For example, the URI view-source:https://example.com should show the source of the page located at https://example.com.
In the early Internet, the View Source technique helped people learn by example to create their own web pages.[2]
On 25 May 2011, the 'view-source' URI scheme was officially registered with IANA[3] per RFC 4395.
Browser support
[edit]Firefox and Internet Explorer both supported the scheme, but support was dropped from Internet Explorer in Windows XP SP2 due to security problems.[4] Firefox also suffered a similar security issue (by combining view-source and JavaScript URIs[5]), but still supported it in Firefox 1.5[6] after being fixed. In 2009, a new discovered bug was fixed in Firefox 3.0.9.[7]
| Browser | Supported? |
|---|---|
| Mozilla Firefox | supported[8] |
| SeaMonkey | supported |
| Netscape | supported |
| Internet Explorer 4, 5 and 6 | supported |
| Internet Explorer 6, 7, and 8 | not supported after Windows XP SP2 |
| Safari 3.2.1 | supported |
| Safari 5, 6 | not supported |
| Opera 7, 8, 9, 10, 11 | not supported |
| Opera 15 and up | supported |
| Google Chrome | supported[9] |
| Web | supported |
| HP webOS | via third-party app (Internalz Pro)[10] |
References
[edit]- ^ Yevstifeyev, Mykyta (2011-04-23). The 'view-source' URI Scheme (Report). Internet Engineering Task Force.
- ^ Sahlin, Doug; Snell, Claudia (2007-02-03). Building Web Sites All-in-One Desk Reference For Dummies. John Wiley & Sons. ISBN 978-0-470-12720-9.
- ^ Yevstifeyev, M. "'view-source' URI scheme registration template". Retrieved 17 July 2011.
- ^ "view-source Protocol". MSDN. Retrieved 2009-02-25.
- ^ mikx (2005-05-21). "Mozilla Firefox view-source:javascript url Code Execution Exploit". milw0rm. Archived from the original on 2007-08-14. Retrieved 2009-02-25.
- ^ jonathan (2005-11-30). "View Source Bug Fixed and a Tip". blogzilla. Retrieved 2009-02-25.
- ^ Fleischer, Gregory (April 21, 2009). "MFSA 2009-17: Same-origin violations when Adobe Flash loaded via view-source scheme". Mozilla. Retrieved 2009-04-22.
- ^ "View Source - Firefox Developer Tools". MDN.
- ^ "Google Chrome's Full List of Special about: Pages". Lifehacker. 4 September 2008.
- ^ Robitaille, Jason (2010-08-28). "Internalz 1.3 brings style with a dark theme and more". PreCentral. Archived from the original on 2011-05-12. Retrieved 2011-02-11.
View-source URI scheme
View on Grokipediaview-source: to a standard URI, such as view-source:https://example.com, to render the fetched resource's raw source—typically as plain text in UTF-8 encoding—rather than its interpreted form.[2] This scheme facilitates debugging, learning, and analysis of web content but is not universally standardized beyond its provisional status.[1]
Specified in Internet Engineering Task Force (IETF) draft document from 2011, the syntax follows Augmented Backus-Naur Form (ABNF) as view-source-uri = "view-source:" absolute-URI, where absolute-URI adheres to RFC 3986.[2] Semantically, applications must retrieve the resource via its embedded URI and present its source code, often in a text/plain or text/html media type, while handling edge cases like non-HTTP URIs (e.g., tel:) by displaying a blank or zero-length response.[2] Encoding follows standard URI percent-encoding rules from RFC 3986, ensuring compatibility with diverse resource types.[1]
In practice, the scheme is supported by most modern web browsers, including Mozilla Firefox and Google Chrome, enabling direct entry in address bars or hyperlink usage to view sources without loading the full page.[2] However, implementations vary in display formatting, with no mandated styling beyond basic text representation, and older browsers like Internet Explorer discontinued support for security reasons.[1] Security considerations include the potential exposure of confidential or copyrighted source material, requiring user caution to avoid unintended data leaks, as outlined in general URI security guidelines.[2] The scheme's change controller is Mykyta Yevstifeyev, and it remains unregistered as permanent due to its application-specific nature.[1]
Definition and Purpose
Definition
The view-source URI scheme is a specialized protocol that allows applications, particularly web browsers, to display the raw source code of a resource identified by an absolute URI, rather than rendering or interpreting its content. It is invoked by prepending "view-source:" to the absolute URI, instructing the client to fetch the resource and present it in a non-executable format, such as plain text, thereby preventing the execution of embedded scripts, styles, or other dynamic elements.[2][1] This scheme is registered with the Internet Assigned Numbers Authority (IANA) as a provisional URI scheme, following the registration procedures outlined in RFC 7595. The formal specification defines its syntax asview-source-uri = "view-source:" absolute-URI, where absolute-URI adheres to the generic syntax in RFC 3986, ensuring compatibility with existing URI structures. Semantically, it focuses on exposing the unaltered bytes returned by the server for resources like HTML documents, typically encoded in UTF-8 as per RFC 3629, without applying client-side processing.[1][2]
In contrast to standard URI schemes such as http or https, which emphasize fetching, parsing, and rendering resources for user interaction, the view-source scheme prioritizes transparency by delivering the raw source data directly, enabling inspection without the risks associated with active content execution. This distinction underscores its role in diagnostic and educational contexts within web applications.[2][1]
Purpose and Benefits
The view-source URI scheme primarily enables users to inspect the raw source code of web resources, such as HTML, CSS, and JavaScript, directly within a web browser without modifying or executing the original page content. This functionality allows developers and learners to examine the unprocessed markup and scripts as they are retrieved from the server, facilitating debugging by revealing discrepancies between intended code and rendered output. For instance, it helps identify issues like malformed tags or unexpected server-side alterations that might not be apparent in the browser's visual representation. One key benefit of the view-source scheme is its embodiment of the "view source" effect, a foundational principle of web architecture that promotes transparency and ease of learning by making data formats human-readable and accessible. This approach simplifies the acquisition of expertise in web technologies, as users can directly study and experiment with source code using basic text tools, fostering innovation and interoperability without requiring specialized software. By demystifying how web pages are constructed, it has historically contributed to the web's growth as an open, educational platform.[3] In modern contexts, the scheme enhances developer workflows through seamless integration with browser tools, allowing quick source inspection during active sessions to verify site authenticity or troubleshoot dynamic content generation. It supports educational transparency by enabling users to scrutinize potentially deceptive pages, such as those with hidden scripts, thereby reinforcing trust in web resources. Additionally, its non-executable nature provides a secure method for analysis, preventing accidental activation of malicious code during review.[4]Syntax and Usage
Syntax
Theview-source URI scheme is formally defined using Augmented Backus-Naur Form (ABNF) as view-source: immediately followed by an absolute URI, where the absolute URI conforms to the generic syntax outlined in RFC 3986, Appendix A.[1][2][5] This structure ensures that the scheme acts solely as a prefix wrapper around a fully qualified resource identifier, without modifying or reinterpreting the underlying URI's components, such as the scheme, authority, path, query, or fragment.[2] For instance, a valid construction might appear as view-source:http://[example.com](/page/Example.com) or view-source:[https](/page/HTTPS)://[example.com](/page/Example.com)/page.[html](/page/HTML)?param=value#fragment, preserving the base URI's syntax and parameters intact for source code retrieval and display.[1]
Relative URIs are explicitly not permitted within the view-source scheme; only absolute URIs are supported to guarantee unambiguous resolution to the target resource's source code.[2] The scheme itself introduces no additional syntactic elements or alterations to the base URI's handling of query parameters or fragments, which are processed according to the rules of the embedded URI's scheme (e.g., HTTP or HTTPS).[6] In web contexts, this primarily applies to HTTP and HTTPS URIs, where the source code—typically HTML, CSS, or JavaScript—is displayed as plain text in UTF-8 encoding.[1]
For edge cases involving non-HTTP schemes, such as view-source:file:///local.html, support is implementation-dependent on the user agent (e.g., web browser), which may display the file's contents if local file access is permitted, though the primary emphasis remains on web-based resources.[2] In such scenarios, if the base URI does not reference a data-bearing resource, applications are recommended to resolve it to a zero-length response with text/plain media type and UTF-8 encoding.[2]
Usage Examples
One common way to use the view-source URI scheme is by entering it directly into a web browser's address bar, such asview-source:https://www.example.com, which prompts the browser to fetch and display the raw HTML source code of the specified page as plain text without rendering it.[2] This approach allows users to inspect the original markup sent from the server, including any server-side generated content.[1]
In more advanced scenarios, the scheme can be incorporated into HTML hyperlinks to provide on-demand source viewing. For example, an anchor element like <a href="view-source:https://www.site.com/page.html" rel="nofollow">View Page Source</a> enables users to click and open the source code in a new tab or window, depending on the browser's handling of the URI.[7] Similarly, bookmarklets can leverage the scheme for quick access; a JavaScript bookmarklet such as javascript:window.location='view-source:'+window.location.href; redirects the current page to its view-source equivalent, facilitating instant inspection without manual typing.[8] These methods are often combined with browser developer consoles, where the scheme URI can be executed via the console for dynamic source examination during active sessions.
The view-source scheme supports several common workflows in web development and education. Developers frequently use it for debugging by comparing the unrendered source—accessed via the address bar or a hyperlink—to the browser's DOM inspector, helping identify discrepancies caused by client-side modifications like JavaScript injections or CSS overrides. In educational contexts, instructors demonstrate web fundamentals by directing students to enter or link to view-source URIs of simple pages, allowing learners to study HTML structure, tags, and attributes directly from real-world examples without needing separate tools.[9] This hands-on approach highlights how browsers interpret markup, making abstract concepts tangible for beginners.
History
Early Development
The view-source URI scheme originated from the need in early web browsers to provide users with access to the underlying HTML source code, promoting education and transparency in the emerging World Wide Web. This capability was first implemented in ViolaWWW, an experimental browser developed starting in 1991 and released in 1992 by Pei-Yuan Wei at the University of California, Berkeley. ViolaWWW featured a dedicated HTML source viewer, allowing users to inspect the raw hypertext markup without editing capabilities, which supported learning and experimentation in the academic environment where the web was initially developed.[10] Building on ViolaWWW's innovations, NCSA Mosaic introduced a more user-friendly source viewing mechanism upon its release on April 22, 1993. Mosaic included a "View Source" option accessible via the File menu, displaying the complete HTML code of any loaded document in a separate window. This feature was designed to demystify web page construction for non-experts, encouraging widespread adoption and self-teaching among users in the nascent web era by revealing how text, images, and links were encoded.[11] The view-source functionality achieved broad popularity and refinement with Netscape Navigator 1.0, released on December 15, 1994, which marked the first major commercial web browser. Netscape integrated source viewing as a menu item, making it far more intuitive than previous implementations. This approach not only facilitated quick inspection for educational purposes but also influenced competing browsers, establishing informal precedents for URI-based access to source code—such as prefixing URLs with "view-source:" in the address bar—long before any official registration.[12]Standardization
The 'view-source' URI scheme was provisionally registered with the Internet Assigned Numbers Authority (IANA) on May 25, 2011, following the guidelines outlined in RFC 4395 for URI scheme registration procedures.[1] This registration defines the scheme as a mechanism for displaying the source code of a resource identified by an absolute URI, without executing it, allowing applications—particularly web browsers—to render the content typically as plain text encoded in UTF-8.[1] The provisional status, rather than permanent, reflects that the scheme's primary specification remains an Internet-Draft rather than a full Request for Comments (RFC).[1] The formal specification effort began with Internet-Draft draft-yevstifeyev-view-source-uri-01, authored by Mykyta Yevstifeyev and published on April 23, 2011.[2] This draft formalized the syntax and intent of the scheme, specifying it as 'view-source:' followed by an absolute URI (per RFC 3986), and recommending display formats such as text/plain or text/html in UTF-8 encoding to ensure consistent representation of the source code.[2] Although the draft did not progress to full RFC status and expired in October 2011, its provisional registration with IANA enabled widespread browser implementations by providing an official reference for interoperability.[2][1] This standardization marked a significant evolution from the scheme's earlier ad-hoc adoption as a browser-specific feature in the 1990s to a recognized URI scheme, promoting cross-browser consistency and reducing implementation uncertainties post-2011.[2] Subsequent updates in browser engines, such as enhanced syntax parsing and security alignments with URI standards like RFC 3986, have built on this foundation to maintain the scheme's utility without requiring further IETF advancement.[2][13]Browser Implementation
Supported Browsers
The view-source URI scheme enjoys broad support in contemporary desktop web browsers as of 2025. Other Chromium-based browsers, such as Brave and Vivaldi, provide full support on desktop platforms, inheriting Chromium's implementation. Google Chrome provides full support across all versions on desktop platforms, allowing users to prepend "view-source:" to any HTTP or HTTPS URL to display the raw HTML source code. Similarly, Mozilla Firefox offers full support in all versions on desktop, rendering the source code in a dedicated view or tab.[2] Microsoft Edge, being Chromium-based, inherits full support on desktop, while Opera from version 15 onward also fully supports the scheme due to its Chromium foundation.[1] Safari does not support the view-source URI scheme directly in the address bar or links post-version 5; source viewing is available only via the Develop menu (after enabling it in Safari > Settings > Advanced). On mobile platforms, support is generally partial; for instance, Chrome for Android exhibits limited functionality, where entering the scheme may trigger a search dropdown instead of directly displaying source, necessitating workarounds like extensions or developer tools. Historically, the scheme originated with early browsers such as Netscape Navigator, where it was supported for viewing page source via menu options and URI prefixes.[14] Internet Explorer versions 4 through 6 also supported it, enabling source display when prefixed to URLs. However, support was discontinued with Windows XP SP2 due to security vulnerabilities that could expose sensitive information or enable attacks, and was not available in Internet Explorer 7 and subsequent versions.[15] The feature was later reintroduced in modern rendering engines like Blink (Chromium) and Gecko (Firefox derivatives), restoring widespread compatibility.[1]| Browser | Version Range | Desktop Support | Mobile Support | Platform Notes |
|---|---|---|---|---|
| Google Chrome | All versions | Full | Partial | Full on Windows/macOS/Linux; limited on Android due to UI changes. |
| Mozilla Firefox | All versions | Full | Partial | Full on desktop; extensions recommended for Android/iOS. |
| Microsoft Edge | Chromium-based (79+) | Full | Partial | Inherits Chrome behavior across platforms. |
| Safari | 5+ | None | None | Source viewing via Develop menu only; no URI scheme support on macOS/iOS. |
| Opera | 15+ | Full | Partial | Chromium-based; similar to Chrome on Android. |
| Internet Explorer | 4–6 | Full | N/A | Dropped post-Windows XP SP2 for security. |
| Netscape Navigator | All versions | Full | N/A | Early implementation via View menu and URI. |
Implementation Details
When a browser encounters a view-source URI, it first parses the scheme to identify the base resource by stripping the "view-source:" prefix, then fetches the content from the underlying URI using standard network protocols. The retrieved content is processed through a specialized rendering pipeline that treats it as plain text, preventing the execution of embedded scripts, application of CSS stylesheets, or loading of iframes to ensure a safe, static display. This results in the source code being rendered in a new tab or window, often with optional syntax highlighting to aid readability.[16][17] In the Blink rendering engine, used by Chrome and Edge, a dedicated handler in the BrowserURLHandlerImpl rewrites the URI and invokes WebContents::ViewSource to load the content into an HTMLViewSourceDocument. This document sets a view-source mode flag (SetIsViewSource(true)), employing an HTMLViewSourceParser that escapes HTML entities and applies basic syntax highlighting for tags and attributes without executing any dynamic elements. Caching behavior in Blink typically involves re-fetching the resource to guarantee the freshest source, though it may leverage the browser's general HTTP cache if headers permit.[18][19][20] The Gecko engine in Firefox handles view-source through the nsViewSourceChannel protocol, which registers the scheme and creates a channel to fetch and wrap the base content in an "application/x-view-source" MIME type document. This integrates with developer tools for enhanced features, such as line-numbered output via generated spans (e.g., ) and CSS-based syntax highlighting applied through viewsource.css classes like .start-tag. Scripts and external resources are explicitly disabled during parsing, and since Firefox 42, the implementation prioritizes cached content from the original load to avoid unnecessary network requests, improving efficiency for repeated views.[17][21][22] Browsers exhibit variations in handling non-text resources; for binary files like images accessed via view-source, the content is displayed as raw bytes interpreted as text, often resulting in unreadable garbled output or, if encoded, a base64 representation. Error responses, such as HTTP 404 pages, are fetched and rendered similarly, showing the server's error document source code with line numbers and highlighting where supported. Accessibility support includes compatibility with screen readers, which treat the output as navigable plain text, though large sources may pose performance challenges for assistive technologies due to volume.[23][24]Security Considerations
Known Vulnerabilities
In 2015, a vulnerability in Mozilla Firefox (MFSA 2015-149, CVE-2015-7214) allowed cross-site reading attacks by exploiting improper handling ofdata: and view-source: URIs, enabling attackers to bypass the same-origin policy and access content from other origins.[25] This issue was reported by security researcher Tsubasa Iinuma and resolved in Firefox 43 by enhancing URI validation to prevent such policy violations.[25]
Early versions of Internet Explorer (prior to Windows XP Service Pack 2) supported the view-source: scheme but exposed source code in ways that risked leaking sensitive data, such as through integration with external editors like Notepad for rendering.[26] Support was subsequently removed in IE 6 SP2 and later versions as part of broader security hardening measures to mitigate potential information disclosure.[27]
In Firefox, additional issues have included WebExtensions using view-source: URLs to circumvent content restrictions (MFSA 2018-06, CVE-2018-5134), allowing extensions to access restricted resources; this was fixed in Firefox 59.[28]
